| 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 26 matching lines...) Expand all Loading... |
| 37 #include "core/animation/CompositorAnimationsTestHelper.h" | 37 #include "core/animation/CompositorAnimationsTestHelper.h" |
| 38 #include "core/animation/ElementAnimations.h" | 38 #include "core/animation/ElementAnimations.h" |
| 39 #include "core/animation/KeyframeEffect.h" | 39 #include "core/animation/KeyframeEffect.h" |
| 40 #include "core/animation/animatable/AnimatableDouble.h" | 40 #include "core/animation/animatable/AnimatableDouble.h" |
| 41 #include "core/animation/animatable/AnimatableFilterOperations.h" | 41 #include "core/animation/animatable/AnimatableFilterOperations.h" |
| 42 #include "core/animation/animatable/AnimatableTransform.h" | 42 #include "core/animation/animatable/AnimatableTransform.h" |
| 43 #include "core/animation/animatable/AnimatableValueTestHelper.h" | 43 #include "core/animation/animatable/AnimatableValueTestHelper.h" |
| 44 #include "core/dom/Document.h" | 44 #include "core/dom/Document.h" |
| 45 #include "core/layout/LayoutObject.h" | 45 #include "core/layout/LayoutObject.h" |
| 46 #include "core/testing/DummyPageHolder.h" | 46 #include "core/testing/DummyPageHolder.h" |
| 47 #include "platform/animation/CompositorAnimation.h" |
| 47 #include "platform/geometry/FloatBox.h" | 48 #include "platform/geometry/FloatBox.h" |
| 48 #include "platform/geometry/IntSize.h" | 49 #include "platform/geometry/IntSize.h" |
| 49 #include "platform/graphics/filters/FilterOperations.h" | 50 #include "platform/graphics/filters/FilterOperations.h" |
| 50 #include "platform/transforms/TransformOperations.h" | 51 #include "platform/transforms/TransformOperations.h" |
| 51 #include "platform/transforms/TranslateTransformOperation.h" | 52 #include "platform/transforms/TranslateTransformOperation.h" |
| 52 #include "public/platform/WebCompositorAnimation.h" | |
| 53 #include "testing/gmock/include/gmock/gmock.h" | 53 #include "testing/gmock/include/gmock/gmock.h" |
| 54 #include "testing/gtest/include/gtest/gtest.h" | 54 #include "testing/gtest/include/gtest/gtest.h" |
| 55 #include "wtf/HashFunctions.h" | 55 #include "wtf/HashFunctions.h" |
| 56 #include "wtf/OwnPtr.h" | 56 #include "wtf/OwnPtr.h" |
| 57 #include "wtf/PassOwnPtr.h" | 57 #include "wtf/PassOwnPtr.h" |
| 58 #include "wtf/PassRefPtr.h" | 58 #include "wtf/PassRefPtr.h" |
| 59 #include "wtf/RefPtr.h" | 59 #include "wtf/RefPtr.h" |
| 60 | 60 |
| 61 namespace blink { | 61 namespace blink { |
| 62 | 62 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 76 CompositorAnimationsImpl::CompositorTiming m_compositorTiming; | 76 CompositorAnimationsImpl::CompositorTiming m_compositorTiming; |
| 77 OwnPtr<AnimatableValueKeyframeVector> m_keyframeVector2; | 77 OwnPtr<AnimatableValueKeyframeVector> m_keyframeVector2; |
| 78 Persistent<AnimatableValueKeyframeEffectModel> m_keyframeAnimationEffect2; | 78 Persistent<AnimatableValueKeyframeEffectModel> m_keyframeAnimationEffect2; |
| 79 OwnPtr<AnimatableValueKeyframeVector> m_keyframeVector5; | 79 OwnPtr<AnimatableValueKeyframeVector> m_keyframeVector5; |
| 80 Persistent<AnimatableValueKeyframeEffectModel> m_keyframeAnimationEffect5; | 80 Persistent<AnimatableValueKeyframeEffectModel> m_keyframeAnimationEffect5; |
| 81 | 81 |
| 82 RefPtrWillBePersistent<Document> m_document; | 82 RefPtrWillBePersistent<Document> m_document; |
| 83 RefPtrWillBePersistent<Element> m_element; | 83 RefPtrWillBePersistent<Element> m_element; |
| 84 Persistent<AnimationTimeline> m_timeline; | 84 Persistent<AnimationTimeline> m_timeline; |
| 85 OwnPtr<DummyPageHolder> m_pageHolder; | 85 OwnPtr<DummyPageHolder> m_pageHolder; |
| 86 WebCompositorSupportMock m_mockCompositor; | 86 CompositorFactoryMock* m_mockCompositorFactory; |
| 87 | 87 |
| 88 virtual void SetUp() | 88 void SetUp() override |
| 89 { | 89 { |
| 90 AnimationCompositorAnimationsTestBase::SetUp(); | 90 AnimationCompositorAnimationsTestBase::SetUp(); |
| 91 setCompositorForTesting(m_mockCompositor); | 91 |
| 92 m_mockCompositorFactory = new CompositorFactoryMock(); |
| 93 CompositorFactory::initializeForTesting(adoptPtr(m_mockCompositorFactory
)); |
| 92 | 94 |
| 93 m_linearTimingFunction = LinearTimingFunction::shared(); | 95 m_linearTimingFunction = LinearTimingFunction::shared(); |
| 94 m_cubicEaseTimingFunction = CubicBezierTimingFunction::preset(CubicBezie
rTimingFunction::Ease); | 96 m_cubicEaseTimingFunction = CubicBezierTimingFunction::preset(CubicBezie
rTimingFunction::Ease); |
| 95 m_cubicCustomTimingFunction = CubicBezierTimingFunction::create(1, 2, 3,
4); | 97 m_cubicCustomTimingFunction = CubicBezierTimingFunction::create(1, 2, 3,
4); |
| 96 m_stepTimingFunction = StepsTimingFunction::create(1, StepsTimingFunctio
n::End); | 98 m_stepTimingFunction = StepsTimingFunction::create(1, StepsTimingFunctio
n::End); |
| 97 | 99 |
| 98 m_timing = createCompositableTiming(); | 100 m_timing = createCompositableTiming(); |
| 99 m_compositorTiming = CompositorAnimationsImpl::CompositorTiming(); | 101 m_compositorTiming = CompositorAnimationsImpl::CompositorTiming(); |
| 100 // Make sure the CompositableTiming is really compositable, otherwise | 102 // Make sure the CompositableTiming is really compositable, otherwise |
| 101 // most other tests will fail. | 103 // most other tests will fail. |
| 102 ASSERT(convertTimingForCompositor(m_timing, m_compositorTiming)); | 104 ASSERT(convertTimingForCompositor(m_timing, m_compositorTiming)); |
| 103 | 105 |
| 104 m_keyframeVector2 = createCompositableFloatKeyframeVector(2); | 106 m_keyframeVector2 = createCompositableFloatKeyframeVector(2); |
| 105 m_keyframeAnimationEffect2 = AnimatableValueKeyframeEffectModel::create(
*m_keyframeVector2); | 107 m_keyframeAnimationEffect2 = AnimatableValueKeyframeEffectModel::create(
*m_keyframeVector2); |
| 106 | 108 |
| 107 m_keyframeVector5 = createCompositableFloatKeyframeVector(5); | 109 m_keyframeVector5 = createCompositableFloatKeyframeVector(5); |
| 108 m_keyframeAnimationEffect5 = AnimatableValueKeyframeEffectModel::create(
*m_keyframeVector5); | 110 m_keyframeAnimationEffect5 = AnimatableValueKeyframeEffectModel::create(
*m_keyframeVector5); |
| 109 | 111 |
| 110 if (RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled()) { | 112 if (RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled()) { |
| 111 EXPECT_CALL(m_mockCompositor, createAnimationTimeline()) | 113 EXPECT_CALL(*m_mockCompositorFactory, createAnimationTimeline()) |
| 112 .WillOnce(Return(new WebCompositorAnimationTimelineMock())); | 114 .WillOnce(Return(new WebCompositorAnimationTimelineMock())); |
| 113 } | 115 } |
| 114 m_pageHolder = DummyPageHolder::create(); | 116 m_pageHolder = DummyPageHolder::create(); |
| 115 m_document = &m_pageHolder->document(); | 117 m_document = &m_pageHolder->document(); |
| 116 m_document->animationClock().resetTimeForTesting(); | 118 m_document->animationClock().resetTimeForTesting(); |
| 117 | 119 |
| 118 if (RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled()) { | 120 if (RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled()) { |
| 119 EXPECT_CALL(m_mockCompositor, createAnimationTimeline()) | 121 EXPECT_CALL(*m_mockCompositorFactory, createAnimationTimeline()) |
| 120 .WillOnce(Return(new WebCompositorAnimationTimelineMock())); | 122 .WillOnce(Return(new WebCompositorAnimationTimelineMock())); |
| 121 } | 123 } |
| 122 m_timeline = AnimationTimeline::create(m_document.get()); | 124 m_timeline = AnimationTimeline::create(m_document.get()); |
| 123 m_timeline->resetForTesting(); | 125 m_timeline->resetForTesting(); |
| 124 m_element = m_document->createElement("test", ASSERT_NO_EXCEPTION); | 126 m_element = m_document->createElement("test", ASSERT_NO_EXCEPTION); |
| 125 } | 127 } |
| 126 | 128 |
| 129 void TearDown() override |
| 130 { |
| 131 m_mockCompositorFactory = nullptr; |
| 132 CompositorFactory::shutdown(); |
| 133 } |
| 134 |
| 127 public: | 135 public: |
| 128 | |
| 129 bool convertTimingForCompositor(const Timing& t, CompositorAnimationsImpl::C
ompositorTiming& out) | 136 bool convertTimingForCompositor(const Timing& t, CompositorAnimationsImpl::C
ompositorTiming& out) |
| 130 { | 137 { |
| 131 return CompositorAnimationsImpl::convertTimingForCompositor(t, 0, out, 1
); | 138 return CompositorAnimationsImpl::convertTimingForCompositor(t, 0, out, 1
); |
| 132 } | 139 } |
| 133 bool isCandidateForAnimationOnCompositor(const Timing& timing, const EffectM
odel& effect) | 140 bool isCandidateForAnimationOnCompositor(const Timing& timing, const EffectM
odel& effect) |
| 134 { | 141 { |
| 135 return CompositorAnimations::instance()->isCandidateForAnimationOnCompos
itor(timing, *m_element.get(), nullptr, effect, 1); | 142 return CompositorAnimations::instance()->isCandidateForAnimationOnCompos
itor(timing, *m_element.get(), nullptr, effect, 1); |
| 136 } | 143 } |
| 137 void getAnimationOnCompositor(Timing& timing, AnimatableValueKeyframeEffectM
odel& effect, Vector<OwnPtr<WebCompositorAnimation>>& animations) | 144 void getAnimationOnCompositor(Timing& timing, AnimatableValueKeyframeEffectM
odel& effect, Vector<OwnPtr<CompositorAnimation>>& animations) |
| 138 { | 145 { |
| 139 return getAnimationOnCompositor(timing, effect, animations, 1); | 146 return getAnimationOnCompositor(timing, effect, animations, 1); |
| 140 } | 147 } |
| 141 void getAnimationOnCompositor(Timing& timing, AnimatableValueKeyframeEffectM
odel& effect, Vector<OwnPtr<WebCompositorAnimation>>& animations, double playerP
laybackRate) | 148 void getAnimationOnCompositor(Timing& timing, AnimatableValueKeyframeEffectM
odel& effect, Vector<OwnPtr<CompositorAnimation>>& animations, double playerPlay
backRate) |
| 142 { | 149 { |
| 143 return CompositorAnimationsImpl::getAnimationOnCompositor(timing, 0, std
::numeric_limits<double>::quiet_NaN(), 0, effect, animations, playerPlaybackRate
); | 150 return CompositorAnimationsImpl::getAnimationOnCompositor(timing, 0, std
::numeric_limits<double>::quiet_NaN(), 0, effect, animations, playerPlaybackRate
); |
| 144 } | 151 } |
| 145 bool getAnimationBounds(FloatBox& boundingBox, const EffectModel& effect, do
uble minValue, double maxValue) | 152 bool getAnimationBounds(FloatBox& boundingBox, const EffectModel& effect, do
uble minValue, double maxValue) |
| 146 { | 153 { |
| 147 return CompositorAnimations::instance()->getAnimatedBoundingBox(bounding
Box, effect, minValue, maxValue); | 154 return CompositorAnimations::instance()->getAnimatedBoundingBox(bounding
Box, effect, minValue, maxValue); |
| 148 } | 155 } |
| 149 | 156 |
| 150 bool duplicateSingleKeyframeAndTestIsCandidateOnResult(AnimatableValueKeyfra
me* frame) | 157 bool duplicateSingleKeyframeAndTestIsCandidateOnResult(AnimatableValueKeyfra
me* frame) |
| 151 { | 158 { |
| (...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 648 { | 655 { |
| 649 // KeyframeEffect to convert | 656 // KeyframeEffect to convert |
| 650 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel( | 657 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel( |
| 651 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
).get(), 0), | 658 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
).get(), 0), |
| 652 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
).get(), 1.0)); | 659 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
).get(), 1.0)); |
| 653 // -- | 660 // -- |
| 654 | 661 |
| 655 // Curve is created | 662 // Curve is created |
| 656 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; | 663 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; |
| 657 ExpectationSet usesMockCurve; | 664 ExpectationSet usesMockCurve; |
| 658 EXPECT_CALL(m_mockCompositor, createFloatAnimationCurve()) | 665 EXPECT_CALL(*m_mockCompositorFactory, createFloatAnimationCurve()) |
| 659 .WillOnce(Return(mockCurvePtr)); | 666 .WillOnce(Return(mockCurvePtr)); |
| 660 | 667 |
| 661 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(0.0, 2.0),
WebCompositorAnimationCurve::TimingFunctionTypeLinear)); | 668 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(CompositorFloatKeyframe(0.0,
2.0), CompositorAnimationCurve::TimingFunctionTypeLinear)); |
| 662 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(1.0, 5.0)))
; | 669 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(CompositorFloatKeyframe(1.0,
5.0))); |
| 663 | 670 |
| 664 // Create animation | 671 // Create animation |
| 665 WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMoc
k(WebCompositorAnimation::TargetPropertyOpacity); | 672 WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMoc
k(CompositorAnimation::TargetPropertyOpacity); |
| 666 ExpectationSet usesMockAnimation; | 673 ExpectationSet usesMockAnimation; |
| 667 | 674 |
| 668 usesMockCurve += EXPECT_CALL(m_mockCompositor, createAnimation(Ref(*mockCurv
ePtr), WebCompositorAnimation::TargetPropertyOpacity, _, _)) | 675 usesMockCurve += EXPECT_CALL(*m_mockCompositorFactory, createAnimation(Ref(*
mockCurvePtr), CompositorAnimation::TargetPropertyOpacity, _, _)) |
| 669 .WillOnce(Return(mockAnimationPtr)); | 676 .WillOnce(Return(mockAnimationPtr)); |
| 670 | 677 |
| 671 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(1)); | 678 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(1)); |
| 672 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(0.0)); | 679 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(0.0)); |
| 673 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setDirection(WebComposit
orAnimation::DirectionNormal)); | 680 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setDirection(CompositorA
nimation::DirectionNormal)); |
| 674 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setPlaybackRate(1)); | 681 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setPlaybackRate(1)); |
| 675 | 682 |
| 676 EXPECT_CALL(*mockAnimationPtr, delete_()) | 683 EXPECT_CALL(*mockAnimationPtr, delete_()) |
| 677 .Times(1) | 684 .Times(1) |
| 678 .After(usesMockAnimation); | 685 .After(usesMockAnimation); |
| 679 EXPECT_CALL(*mockCurvePtr, delete_()) | 686 EXPECT_CALL(*mockCurvePtr, delete_()) |
| 680 .Times(1) | 687 .Times(1) |
| 681 .After(usesMockCurve); | 688 .After(usesMockCurve); |
| 682 | 689 |
| 683 // Go! | 690 // Go! |
| 684 Vector<OwnPtr<WebCompositorAnimation>> result; | 691 Vector<OwnPtr<CompositorAnimation>> result; |
| 685 getAnimationOnCompositor(m_timing, *effect, result); | 692 getAnimationOnCompositor(m_timing, *effect, result); |
| 686 EXPECT_EQ(1U, result.size()); | 693 EXPECT_EQ(1U, result.size()); |
| 687 result[0].clear(); | 694 result[0].clear(); |
| 688 } | 695 } |
| 689 | 696 |
| 690 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationDuration) | 697 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationDuration) |
| 691 { | 698 { |
| 692 // KeyframeEffect to convert | 699 // KeyframeEffect to convert |
| 693 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel( | 700 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel( |
| 694 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
).get(), 0), | 701 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
).get(), 0), |
| 695 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
).get(), 1.0)); | 702 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
).get(), 1.0)); |
| 696 | 703 |
| 697 m_timing.iterationDuration = 10.0; | 704 m_timing.iterationDuration = 10.0; |
| 698 // -- | 705 // -- |
| 699 | 706 |
| 700 // Curve is created | 707 // Curve is created |
| 701 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; | 708 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; |
| 702 ExpectationSet usesMockCurve; | 709 ExpectationSet usesMockCurve; |
| 703 EXPECT_CALL(m_mockCompositor, createFloatAnimationCurve()) | 710 EXPECT_CALL(*m_mockCompositorFactory, createFloatAnimationCurve()) |
| 704 .WillOnce(Return(mockCurvePtr)); | 711 .WillOnce(Return(mockCurvePtr)); |
| 705 | 712 |
| 706 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(0.0, 2.0),
WebCompositorAnimationCurve::TimingFunctionTypeLinear)); | 713 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(CompositorFloatKeyframe(0.0,
2.0), CompositorAnimationCurve::TimingFunctionTypeLinear)); |
| 707 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(10.0, 5.0))
); | 714 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(CompositorFloatKeyframe(10.0
, 5.0))); |
| 708 | 715 |
| 709 // Create animation | 716 // Create animation |
| 710 WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMoc
k(WebCompositorAnimation::TargetPropertyOpacity); | 717 WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMoc
k(CompositorAnimation::TargetPropertyOpacity); |
| 711 ExpectationSet usesMockAnimation; | 718 ExpectationSet usesMockAnimation; |
| 712 | 719 |
| 713 usesMockCurve += EXPECT_CALL(m_mockCompositor, createAnimation(Ref(*mockCurv
ePtr), WebCompositorAnimation::TargetPropertyOpacity, _, _)) | 720 usesMockCurve += EXPECT_CALL(*m_mockCompositorFactory, createAnimation(Ref(*
mockCurvePtr), CompositorAnimation::TargetPropertyOpacity, _, _)) |
| 714 .WillOnce(Return(mockAnimationPtr)); | 721 .WillOnce(Return(mockAnimationPtr)); |
| 715 | 722 |
| 716 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(1)); | 723 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(1)); |
| 717 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(0.0)); | 724 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(0.0)); |
| 718 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setDirection(WebComposit
orAnimation::DirectionNormal)); | 725 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setDirection(CompositorA
nimation::DirectionNormal)); |
| 719 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setPlaybackRate(1)); | 726 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setPlaybackRate(1)); |
| 720 | 727 |
| 721 EXPECT_CALL(*mockAnimationPtr, delete_()) | 728 EXPECT_CALL(*mockAnimationPtr, delete_()) |
| 722 .Times(1) | 729 .Times(1) |
| 723 .After(usesMockAnimation); | 730 .After(usesMockAnimation); |
| 724 EXPECT_CALL(*mockCurvePtr, delete_()) | 731 EXPECT_CALL(*mockCurvePtr, delete_()) |
| 725 .Times(1) | 732 .Times(1) |
| 726 .After(usesMockCurve); | 733 .After(usesMockCurve); |
| 727 | 734 |
| 728 // Go! | 735 // Go! |
| 729 Vector<OwnPtr<WebCompositorAnimation>> result; | 736 Vector<OwnPtr<CompositorAnimation>> result; |
| 730 getAnimationOnCompositor(m_timing, *effect, result); | 737 getAnimationOnCompositor(m_timing, *effect, result); |
| 731 EXPECT_EQ(1U, result.size()); | 738 EXPECT_EQ(1U, result.size()); |
| 732 result[0].clear(); | 739 result[0].clear(); |
| 733 } | 740 } |
| 734 | 741 |
| 735 TEST_F(AnimationCompositorAnimationsTest, createMultipleKeyframeOpacityAnimation
Linear) | 742 TEST_F(AnimationCompositorAnimationsTest, createMultipleKeyframeOpacityAnimation
Linear) |
| 736 { | 743 { |
| 737 // KeyframeEffect to convert | 744 // KeyframeEffect to convert |
| 738 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel( | 745 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel( |
| 739 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
).get(), 0), | 746 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
).get(), 0), |
| 740 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(-1.
0).get(), 0.25), | 747 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(-1.
0).get(), 0.25), |
| 741 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(20.
0).get(), 0.5), | 748 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(20.
0).get(), 0.5), |
| 742 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
).get(), 1.0)); | 749 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
).get(), 1.0)); |
| 743 | 750 |
| 744 m_timing.iterationCount = 5; | 751 m_timing.iterationCount = 5; |
| 745 m_timing.direction = Timing::PlaybackDirectionAlternate; | 752 m_timing.direction = Timing::PlaybackDirectionAlternate; |
| 746 m_timing.playbackRate = 2.0; | 753 m_timing.playbackRate = 2.0; |
| 747 // -- | 754 // -- |
| 748 | 755 |
| 749 // Curve is created | 756 // Curve is created |
| 750 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock(); | 757 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock(); |
| 751 ExpectationSet usesMockCurve; | 758 ExpectationSet usesMockCurve; |
| 752 | 759 |
| 753 EXPECT_CALL(m_mockCompositor, createFloatAnimationCurve()) | 760 EXPECT_CALL(*m_mockCompositorFactory, createFloatAnimationCurve()) |
| 754 .WillOnce(Return(mockCurvePtr)); | 761 .WillOnce(Return(mockCurvePtr)); |
| 755 | 762 |
| 756 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(0.0, 2.0),
WebCompositorAnimationCurve::TimingFunctionTypeLinear)); | 763 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(CompositorFloatKeyframe(0.0,
2.0), CompositorAnimationCurve::TimingFunctionTypeLinear)); |
| 757 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(0.25, -1.0)
, WebCompositorAnimationCurve::TimingFunctionTypeLinear)); | 764 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(CompositorFloatKeyframe(0.25
, -1.0), CompositorAnimationCurve::TimingFunctionTypeLinear)); |
| 758 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(0.5, 20.0),
WebCompositorAnimationCurve::TimingFunctionTypeLinear)); | 765 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(CompositorFloatKeyframe(0.5,
20.0), CompositorAnimationCurve::TimingFunctionTypeLinear)); |
| 759 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(1.0, 5.0)))
; | 766 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(CompositorFloatKeyframe(1.0,
5.0))); |
| 760 | 767 |
| 761 // KeyframeEffect is created | 768 // KeyframeEffect is created |
| 762 WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMoc
k(WebCompositorAnimation::TargetPropertyOpacity); | 769 WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMoc
k(CompositorAnimation::TargetPropertyOpacity); |
| 763 ExpectationSet usesMockAnimation; | 770 ExpectationSet usesMockAnimation; |
| 764 | 771 |
| 765 usesMockCurve += EXPECT_CALL(m_mockCompositor, createAnimation(Ref(*mockCurv
ePtr), WebCompositorAnimation::TargetPropertyOpacity, _, _)) | 772 usesMockCurve += EXPECT_CALL(*m_mockCompositorFactory, createAnimation(Ref(*
mockCurvePtr), CompositorAnimation::TargetPropertyOpacity, _, _)) |
| 766 .WillOnce(Return(mockAnimationPtr)); | 773 .WillOnce(Return(mockAnimationPtr)); |
| 767 | 774 |
| 768 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(5)); | 775 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(5)); |
| 769 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(0.0)); | 776 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(0.0)); |
| 770 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setDirection(WebComposit
orAnimation::DirectionAlternate)); | 777 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setDirection(CompositorA
nimation::DirectionAlternate)); |
| 771 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setPlaybackRate(2.0)); | 778 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setPlaybackRate(2.0)); |
| 772 | 779 |
| 773 EXPECT_CALL(*mockAnimationPtr, delete_()) | 780 EXPECT_CALL(*mockAnimationPtr, delete_()) |
| 774 .Times(1) | 781 .Times(1) |
| 775 .After(usesMockAnimation); | 782 .After(usesMockAnimation); |
| 776 EXPECT_CALL(*mockCurvePtr, delete_()) | 783 EXPECT_CALL(*mockCurvePtr, delete_()) |
| 777 .Times(1) | 784 .Times(1) |
| 778 .After(usesMockCurve); | 785 .After(usesMockCurve); |
| 779 | 786 |
| 780 // Go! | 787 // Go! |
| 781 Vector<OwnPtr<WebCompositorAnimation>> result; | 788 Vector<OwnPtr<CompositorAnimation>> result; |
| 782 getAnimationOnCompositor(m_timing, *effect, result); | 789 getAnimationOnCompositor(m_timing, *effect, result); |
| 783 EXPECT_EQ(1U, result.size()); | 790 EXPECT_EQ(1U, result.size()); |
| 784 result[0].clear(); | 791 result[0].clear(); |
| 785 } | 792 } |
| 786 | 793 |
| 787 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationStartDelay
) | 794 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationStartDelay
) |
| 788 { | 795 { |
| 789 // KeyframeEffect to convert | 796 // KeyframeEffect to convert |
| 790 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel( | 797 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel( |
| 791 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
).get(), 0), | 798 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
).get(), 0), |
| 792 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
).get(), 1.0)); | 799 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
).get(), 1.0)); |
| 793 | 800 |
| 794 m_timing.iterationCount = 5.0; | 801 m_timing.iterationCount = 5.0; |
| 795 m_timing.iterationDuration = 1.75; | 802 m_timing.iterationDuration = 1.75; |
| 796 m_timing.startDelay = 3.25; | 803 m_timing.startDelay = 3.25; |
| 797 // -- | 804 // -- |
| 798 | 805 |
| 799 // Curve is created | 806 // Curve is created |
| 800 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; | 807 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; |
| 801 ExpectationSet usesMockCurve; | 808 ExpectationSet usesMockCurve; |
| 802 EXPECT_CALL(m_mockCompositor, createFloatAnimationCurve()) | 809 EXPECT_CALL(*m_mockCompositorFactory, createFloatAnimationCurve()) |
| 803 .WillOnce(Return(mockCurvePtr)); | 810 .WillOnce(Return(mockCurvePtr)); |
| 804 | 811 |
| 805 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(0.0, 2.0),
WebCompositorAnimationCurve::TimingFunctionTypeLinear)); | 812 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(CompositorFloatKeyframe(0.0,
2.0), CompositorAnimationCurve::TimingFunctionTypeLinear)); |
| 806 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(1.75, 5.0))
); | 813 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(CompositorFloatKeyframe(1.75
, 5.0))); |
| 807 | 814 |
| 808 // Create animation | 815 // Create animation |
| 809 WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMoc
k(WebCompositorAnimation::TargetPropertyOpacity); | 816 WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMoc
k(CompositorAnimation::TargetPropertyOpacity); |
| 810 ExpectationSet usesMockAnimation; | 817 ExpectationSet usesMockAnimation; |
| 811 | 818 |
| 812 usesMockCurve += EXPECT_CALL(m_mockCompositor, createAnimation(Ref(*mockCurv
ePtr), WebCompositorAnimation::TargetPropertyOpacity, _, _)) | 819 usesMockCurve += EXPECT_CALL(*m_mockCompositorFactory, createAnimation(Ref(*
mockCurvePtr), CompositorAnimation::TargetPropertyOpacity, _, _)) |
| 813 .WillOnce(Return(mockAnimationPtr)); | 820 .WillOnce(Return(mockAnimationPtr)); |
| 814 | 821 |
| 815 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(5)); | 822 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(5)); |
| 816 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(-3.25)); | 823 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(-3.25)); |
| 817 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setDirection(WebComposit
orAnimation::DirectionNormal)); | 824 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setDirection(CompositorA
nimation::DirectionNormal)); |
| 818 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setPlaybackRate(1)); | 825 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setPlaybackRate(1)); |
| 819 | 826 |
| 820 EXPECT_CALL(*mockAnimationPtr, delete_()) | 827 EXPECT_CALL(*mockAnimationPtr, delete_()) |
| 821 .Times(1) | 828 .Times(1) |
| 822 .After(usesMockAnimation); | 829 .After(usesMockAnimation); |
| 823 EXPECT_CALL(*mockCurvePtr, delete_()) | 830 EXPECT_CALL(*mockCurvePtr, delete_()) |
| 824 .Times(1) | 831 .Times(1) |
| 825 .After(usesMockCurve); | 832 .After(usesMockCurve); |
| 826 | 833 |
| 827 // Go! | 834 // Go! |
| 828 Vector<OwnPtr<WebCompositorAnimation>> result; | 835 Vector<OwnPtr<CompositorAnimation>> result; |
| 829 getAnimationOnCompositor(m_timing, *effect, result); | 836 getAnimationOnCompositor(m_timing, *effect, result); |
| 830 EXPECT_EQ(1U, result.size()); | 837 EXPECT_EQ(1U, result.size()); |
| 831 result[0].clear(); | 838 result[0].clear(); |
| 832 } | 839 } |
| 833 | 840 |
| 834 TEST_F(AnimationCompositorAnimationsTest, createMultipleKeyframeOpacityAnimation
Chained) | 841 TEST_F(AnimationCompositorAnimationsTest, createMultipleKeyframeOpacityAnimation
Chained) |
| 835 { | 842 { |
| 836 // KeyframeEffect to convert | 843 // KeyframeEffect to convert |
| 837 AnimatableValueKeyframeVector frames; | 844 AnimatableValueKeyframeVector frames; |
| 838 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(2.0).get(), 0)); | 845 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(2.0).get(), 0)); |
| 839 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(-1.0).get(), 0.25)); | 846 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(-1.0).get(), 0.25)); |
| 840 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(20.0).get(), 0.5)); | 847 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(20.0).get(), 0.5)); |
| 841 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(5.0).get(), 1.0)); | 848 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(5.0).get(), 1.0)); |
| 842 frames[0]->setEasing(m_cubicEaseTimingFunction.get()); | 849 frames[0]->setEasing(m_cubicEaseTimingFunction.get()); |
| 843 frames[1]->setEasing(m_linearTimingFunction.get()); | 850 frames[1]->setEasing(m_linearTimingFunction.get()); |
| 844 frames[2]->setEasing(m_cubicCustomTimingFunction.get()); | 851 frames[2]->setEasing(m_cubicCustomTimingFunction.get()); |
| 845 AnimatableValueKeyframeEffectModel* effect = AnimatableValueKeyframeEffectMo
del::create(frames); | 852 AnimatableValueKeyframeEffectModel* effect = AnimatableValueKeyframeEffectMo
del::create(frames); |
| 846 | 853 |
| 847 m_timing.timingFunction = m_linearTimingFunction.get(); | 854 m_timing.timingFunction = m_linearTimingFunction.get(); |
| 848 m_timing.iterationDuration = 2.0; | 855 m_timing.iterationDuration = 2.0; |
| 849 m_timing.iterationCount = 10; | 856 m_timing.iterationCount = 10; |
| 850 m_timing.direction = Timing::PlaybackDirectionAlternate; | 857 m_timing.direction = Timing::PlaybackDirectionAlternate; |
| 851 // -- | 858 // -- |
| 852 | 859 |
| 853 // Curve is created | 860 // Curve is created |
| 854 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock(); | 861 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock(); |
| 855 ExpectationSet usesMockCurve; | 862 ExpectationSet usesMockCurve; |
| 856 | 863 |
| 857 EXPECT_CALL(m_mockCompositor, createFloatAnimationCurve()) | 864 EXPECT_CALL(*m_mockCompositorFactory, createFloatAnimationCurve()) |
| 858 .WillOnce(Return(mockCurvePtr)); | 865 .WillOnce(Return(mockCurvePtr)); |
| 859 | 866 |
| 860 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(0.0, 2.0),
WebCompositorAnimationCurve::TimingFunctionTypeEase)); | 867 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(CompositorFloatKeyframe(0.0,
2.0), CompositorAnimationCurve::TimingFunctionTypeEase)); |
| 861 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(0.5, -1.0),
WebCompositorAnimationCurve::TimingFunctionTypeLinear)); | 868 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(CompositorFloatKeyframe(0.5,
-1.0), CompositorAnimationCurve::TimingFunctionTypeLinear)); |
| 862 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(1.0, 20.0),
1.0, 2.0, 3.0, 4.0)); | 869 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(CompositorFloatKeyframe(1.0,
20.0), 1.0, 2.0, 3.0, 4.0)); |
| 863 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(2.0, 5.0)))
; | 870 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(CompositorFloatKeyframe(2.0,
5.0))); |
| 864 | 871 |
| 865 // KeyframeEffect is created | 872 // KeyframeEffect is created |
| 866 WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMoc
k(WebCompositorAnimation::TargetPropertyOpacity); | 873 WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMoc
k(CompositorAnimation::TargetPropertyOpacity); |
| 867 ExpectationSet usesMockAnimation; | 874 ExpectationSet usesMockAnimation; |
| 868 | 875 |
| 869 usesMockCurve += EXPECT_CALL(m_mockCompositor, createAnimation(Ref(*mockCurv
ePtr), WebCompositorAnimation::TargetPropertyOpacity, _, _)) | 876 usesMockCurve += EXPECT_CALL(*m_mockCompositorFactory, createAnimation(Ref(*
mockCurvePtr), CompositorAnimation::TargetPropertyOpacity, _, _)) |
| 870 .WillOnce(Return(mockAnimationPtr)); | 877 .WillOnce(Return(mockAnimationPtr)); |
| 871 | 878 |
| 872 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(10)); | 879 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(10)); |
| 873 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(0.0)); | 880 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(0.0)); |
| 874 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setDirection(WebComposit
orAnimation::DirectionAlternate)); | 881 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setDirection(CompositorA
nimation::DirectionAlternate)); |
| 875 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setPlaybackRate(1)); | 882 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setPlaybackRate(1)); |
| 876 | 883 |
| 877 EXPECT_CALL(*mockAnimationPtr, delete_()) | 884 EXPECT_CALL(*mockAnimationPtr, delete_()) |
| 878 .Times(1) | 885 .Times(1) |
| 879 .After(usesMockAnimation); | 886 .After(usesMockAnimation); |
| 880 EXPECT_CALL(*mockCurvePtr, delete_()) | 887 EXPECT_CALL(*mockCurvePtr, delete_()) |
| 881 .Times(1) | 888 .Times(1) |
| 882 .After(usesMockCurve); | 889 .After(usesMockCurve); |
| 883 | 890 |
| 884 // Go! | 891 // Go! |
| 885 Vector<OwnPtr<WebCompositorAnimation>> result; | 892 Vector<OwnPtr<CompositorAnimation>> result; |
| 886 getAnimationOnCompositor(m_timing, *effect, result); | 893 getAnimationOnCompositor(m_timing, *effect, result); |
| 887 EXPECT_EQ(1U, result.size()); | 894 EXPECT_EQ(1U, result.size()); |
| 888 result[0].clear(); | 895 result[0].clear(); |
| 889 } | 896 } |
| 890 | 897 |
| 891 TEST_F(AnimationCompositorAnimationsTest, createReversedOpacityAnimation) | 898 TEST_F(AnimationCompositorAnimationsTest, createReversedOpacityAnimation) |
| 892 { | 899 { |
| 893 RefPtr<TimingFunction> cubicEasyFlipTimingFunction = CubicBezierTimingFuncti
on::create(0.0, 0.0, 0.0, 1.0); | 900 RefPtr<TimingFunction> cubicEasyFlipTimingFunction = CubicBezierTimingFuncti
on::create(0.0, 0.0, 0.0, 1.0); |
| 894 | 901 |
| 895 // KeyframeEffect to convert | 902 // KeyframeEffect to convert |
| 896 AnimatableValueKeyframeVector frames; | 903 AnimatableValueKeyframeVector frames; |
| 897 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(2.0).get(), 0)); | 904 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(2.0).get(), 0)); |
| 898 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(-1.0).get(), 0.25)); | 905 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(-1.0).get(), 0.25)); |
| 899 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(20.0).get(), 0.5)); | 906 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(20.0).get(), 0.5)); |
| 900 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(5.0).get(), 1.0)); | 907 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(5.0).get(), 1.0)); |
| 901 frames[0]->setEasing(CubicBezierTimingFunction::preset(CubicBezierTimingFunc
tion::EaseIn)); | 908 frames[0]->setEasing(CubicBezierTimingFunction::preset(CubicBezierTimingFunc
tion::EaseIn)); |
| 902 frames[1]->setEasing(m_linearTimingFunction.get()); | 909 frames[1]->setEasing(m_linearTimingFunction.get()); |
| 903 frames[2]->setEasing(cubicEasyFlipTimingFunction.get()); | 910 frames[2]->setEasing(cubicEasyFlipTimingFunction.get()); |
| 904 AnimatableValueKeyframeEffectModel* effect = AnimatableValueKeyframeEffectMo
del::create(frames); | 911 AnimatableValueKeyframeEffectModel* effect = AnimatableValueKeyframeEffectMo
del::create(frames); |
| 905 | 912 |
| 906 m_timing.timingFunction = m_linearTimingFunction.get(); | 913 m_timing.timingFunction = m_linearTimingFunction.get(); |
| 907 m_timing.iterationCount = 10; | 914 m_timing.iterationCount = 10; |
| 908 m_timing.direction = Timing::PlaybackDirectionAlternateReverse; | 915 m_timing.direction = Timing::PlaybackDirectionAlternateReverse; |
| 909 // -- | 916 // -- |
| 910 | 917 |
| 911 // Curve is created | 918 // Curve is created |
| 912 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock(); | 919 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock(); |
| 913 ExpectationSet usesMockCurve; | 920 ExpectationSet usesMockCurve; |
| 914 | 921 |
| 915 EXPECT_CALL(m_mockCompositor, createFloatAnimationCurve()) | 922 EXPECT_CALL(*m_mockCompositorFactory, createFloatAnimationCurve()) |
| 916 .WillOnce(Return(mockCurvePtr)); | 923 .WillOnce(Return(mockCurvePtr)); |
| 917 | 924 |
| 918 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(0.0, 2.0),
WebCompositorAnimationCurve::TimingFunctionTypeEaseIn)); | 925 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(CompositorFloatKeyframe(0.0,
2.0), CompositorAnimationCurve::TimingFunctionTypeEaseIn)); |
| 919 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(0.25, -1.0)
, WebCompositorAnimationCurve::TimingFunctionTypeLinear)); | 926 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(CompositorFloatKeyframe(0.25
, -1.0), CompositorAnimationCurve::TimingFunctionTypeLinear)); |
| 920 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(0.5, 20.0),
0.0, 0.0, 0.0, 1.0)); | 927 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(CompositorFloatKeyframe(0.5,
20.0), 0.0, 0.0, 0.0, 1.0)); |
| 921 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(1.0, 5.0)))
; | 928 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(CompositorFloatKeyframe(1.0,
5.0))); |
| 922 | 929 |
| 923 // Create the animation | 930 // Create the animation |
| 924 WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMoc
k(WebCompositorAnimation::TargetPropertyOpacity); | 931 WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMoc
k(CompositorAnimation::TargetPropertyOpacity); |
| 925 ExpectationSet usesMockAnimation; | 932 ExpectationSet usesMockAnimation; |
| 926 | 933 |
| 927 usesMockCurve += EXPECT_CALL(m_mockCompositor, createAnimation(Ref(*mockCurv
ePtr), WebCompositorAnimation::TargetPropertyOpacity, _, _)) | 934 usesMockCurve += EXPECT_CALL(*m_mockCompositorFactory, createAnimation(Ref(*
mockCurvePtr), CompositorAnimation::TargetPropertyOpacity, _, _)) |
| 928 .WillOnce(Return(mockAnimationPtr)); | 935 .WillOnce(Return(mockAnimationPtr)); |
| 929 | 936 |
| 930 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(10)); | 937 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(10)); |
| 931 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(0.0)); | 938 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(0.0)); |
| 932 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setDirection(WebComposit
orAnimation::DirectionAlternateReverse)); | 939 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setDirection(CompositorA
nimation::DirectionAlternateReverse)); |
| 933 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setPlaybackRate(1)); | 940 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setPlaybackRate(1)); |
| 934 | 941 |
| 935 EXPECT_CALL(*mockAnimationPtr, delete_()) | 942 EXPECT_CALL(*mockAnimationPtr, delete_()) |
| 936 .Times(1) | 943 .Times(1) |
| 937 .After(usesMockAnimation); | 944 .After(usesMockAnimation); |
| 938 EXPECT_CALL(*mockCurvePtr, delete_()) | 945 EXPECT_CALL(*mockCurvePtr, delete_()) |
| 939 .Times(1) | 946 .Times(1) |
| 940 .After(usesMockCurve); | 947 .After(usesMockCurve); |
| 941 | 948 |
| 942 // Go! | 949 // Go! |
| 943 Vector<OwnPtr<WebCompositorAnimation>> result; | 950 Vector<OwnPtr<CompositorAnimation>> result; |
| 944 getAnimationOnCompositor(m_timing, *effect, result); | 951 getAnimationOnCompositor(m_timing, *effect, result); |
| 945 EXPECT_EQ(1U, result.size()); | 952 EXPECT_EQ(1U, result.size()); |
| 946 result[0].clear(); | 953 result[0].clear(); |
| 947 } | 954 } |
| 948 | 955 |
| 949 TEST_F(AnimationCompositorAnimationsTest, createReversedOpacityAnimationNegative
StartDelay) | 956 TEST_F(AnimationCompositorAnimationsTest, createReversedOpacityAnimationNegative
StartDelay) |
| 950 { | 957 { |
| 951 // KeyframeEffect to convert | 958 // KeyframeEffect to convert |
| 952 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel( | 959 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel( |
| 953 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
).get(), 0), | 960 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
).get(), 0), |
| 954 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
).get(), 1.0)); | 961 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
).get(), 1.0)); |
| 955 | 962 |
| 956 m_timing.iterationCount = 5.0; | 963 m_timing.iterationCount = 5.0; |
| 957 m_timing.iterationDuration = 1.5; | 964 m_timing.iterationDuration = 1.5; |
| 958 m_timing.startDelay = -3; | 965 m_timing.startDelay = -3; |
| 959 m_timing.direction = Timing::PlaybackDirectionAlternateReverse; | 966 m_timing.direction = Timing::PlaybackDirectionAlternateReverse; |
| 960 // -- | 967 // -- |
| 961 | 968 |
| 962 // Curve is created | 969 // Curve is created |
| 963 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; | 970 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; |
| 964 ExpectationSet usesMockCurve; | 971 ExpectationSet usesMockCurve; |
| 965 EXPECT_CALL(m_mockCompositor, createFloatAnimationCurve()) | 972 EXPECT_CALL(*m_mockCompositorFactory, createFloatAnimationCurve()) |
| 966 .WillOnce(Return(mockCurvePtr)); | 973 .WillOnce(Return(mockCurvePtr)); |
| 967 | 974 |
| 968 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(0.0, 2.0),
WebCompositorAnimationCurve::TimingFunctionTypeLinear)); | 975 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(CompositorFloatKeyframe(0.0,
2.0), CompositorAnimationCurve::TimingFunctionTypeLinear)); |
| 969 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(1.5, 5.0)))
; | 976 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(CompositorFloatKeyframe(1.5,
5.0))); |
| 970 | 977 |
| 971 // Create animation | 978 // Create animation |
| 972 WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMoc
k(WebCompositorAnimation::TargetPropertyOpacity); | 979 WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMoc
k(CompositorAnimation::TargetPropertyOpacity); |
| 973 ExpectationSet usesMockAnimation; | 980 ExpectationSet usesMockAnimation; |
| 974 | 981 |
| 975 usesMockCurve += EXPECT_CALL(m_mockCompositor, createAnimation(Ref(*mockCurv
ePtr), WebCompositorAnimation::TargetPropertyOpacity, _, _)) | 982 usesMockCurve += EXPECT_CALL(*m_mockCompositorFactory, createAnimation(Ref(*
mockCurvePtr), CompositorAnimation::TargetPropertyOpacity, _, _)) |
| 976 .WillOnce(Return(mockAnimationPtr)); | 983 .WillOnce(Return(mockAnimationPtr)); |
| 977 | 984 |
| 978 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(5)); | 985 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(5)); |
| 979 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(3.0)); | 986 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(3.0)); |
| 980 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setDirection(WebComposit
orAnimation::DirectionAlternateReverse)); | 987 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setDirection(CompositorA
nimation::DirectionAlternateReverse)); |
| 981 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setPlaybackRate(1)); | 988 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setPlaybackRate(1)); |
| 982 | 989 |
| 983 EXPECT_CALL(*mockAnimationPtr, delete_()) | 990 EXPECT_CALL(*mockAnimationPtr, delete_()) |
| 984 .Times(1) | 991 .Times(1) |
| 985 .After(usesMockAnimation); | 992 .After(usesMockAnimation); |
| 986 EXPECT_CALL(*mockCurvePtr, delete_()) | 993 EXPECT_CALL(*mockCurvePtr, delete_()) |
| 987 .Times(1) | 994 .Times(1) |
| 988 .After(usesMockCurve); | 995 .After(usesMockCurve); |
| 989 | 996 |
| 990 // Go! | 997 // Go! |
| 991 Vector<OwnPtr<WebCompositorAnimation>> result; | 998 Vector<OwnPtr<CompositorAnimation>> result; |
| 992 getAnimationOnCompositor(m_timing, *effect, result); | 999 getAnimationOnCompositor(m_timing, *effect, result); |
| 993 EXPECT_EQ(1U, result.size()); | 1000 EXPECT_EQ(1U, result.size()); |
| 994 result[0].clear(); | 1001 result[0].clear(); |
| 995 } | 1002 } |
| 996 | 1003 |
| 997 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationPlaybackRa
tes) | 1004 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationPlaybackRa
tes) |
| 998 { | 1005 { |
| 999 // KeyframeEffect to convert | 1006 // KeyframeEffect to convert |
| 1000 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel( | 1007 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel( |
| 1001 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
).get(), 0), | 1008 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
).get(), 0), |
| 1002 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
).get(), 1.0)); | 1009 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
).get(), 1.0)); |
| 1003 | 1010 |
| 1004 m_timing.playbackRate = 2; | 1011 m_timing.playbackRate = 2; |
| 1005 // -- | 1012 // -- |
| 1006 | 1013 |
| 1007 // Curve is created | 1014 // Curve is created |
| 1008 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; | 1015 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; |
| 1009 ExpectationSet usesMockCurve; | 1016 ExpectationSet usesMockCurve; |
| 1010 EXPECT_CALL(m_mockCompositor, createFloatAnimationCurve()) | 1017 EXPECT_CALL(*m_mockCompositorFactory, createFloatAnimationCurve()) |
| 1011 .WillOnce(Return(mockCurvePtr)); | 1018 .WillOnce(Return(mockCurvePtr)); |
| 1012 | 1019 |
| 1013 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(0.0, 2.0),
WebCompositorAnimationCurve::TimingFunctionTypeLinear)); | 1020 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(CompositorFloatKeyframe(0.0,
2.0), CompositorAnimationCurve::TimingFunctionTypeLinear)); |
| 1014 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(1.0, 5.0)))
; | 1021 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(CompositorFloatKeyframe(1.0,
5.0))); |
| 1015 | 1022 |
| 1016 // Create animation | 1023 // Create animation |
| 1017 WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMoc
k(WebCompositorAnimation::TargetPropertyOpacity); | 1024 WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMoc
k(CompositorAnimation::TargetPropertyOpacity); |
| 1018 ExpectationSet usesMockAnimation; | 1025 ExpectationSet usesMockAnimation; |
| 1019 | 1026 |
| 1020 usesMockCurve += EXPECT_CALL(m_mockCompositor, createAnimation(Ref(*mockCurv
ePtr), WebCompositorAnimation::TargetPropertyOpacity, _, _)) | 1027 usesMockCurve += EXPECT_CALL(*m_mockCompositorFactory, createAnimation(Ref(*
mockCurvePtr), CompositorAnimation::TargetPropertyOpacity, _, _)) |
| 1021 .WillOnce(Return(mockAnimationPtr)); | 1028 .WillOnce(Return(mockAnimationPtr)); |
| 1022 | 1029 |
| 1023 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(1)); | 1030 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(1)); |
| 1024 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(0.0)); | 1031 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(0.0)); |
| 1025 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setDirection(WebComposit
orAnimation::DirectionNormal)); | 1032 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setDirection(CompositorA
nimation::DirectionNormal)); |
| 1026 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setPlaybackRate(-3)); | 1033 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setPlaybackRate(-3)); |
| 1027 | 1034 |
| 1028 EXPECT_CALL(*mockAnimationPtr, delete_()) | 1035 EXPECT_CALL(*mockAnimationPtr, delete_()) |
| 1029 .Times(1) | 1036 .Times(1) |
| 1030 .After(usesMockAnimation); | 1037 .After(usesMockAnimation); |
| 1031 EXPECT_CALL(*mockCurvePtr, delete_()) | 1038 EXPECT_CALL(*mockCurvePtr, delete_()) |
| 1032 .Times(1) | 1039 .Times(1) |
| 1033 .After(usesMockCurve); | 1040 .After(usesMockCurve); |
| 1034 | 1041 |
| 1035 // Go! | 1042 // Go! |
| 1036 Vector<OwnPtr<WebCompositorAnimation>> result; | 1043 Vector<OwnPtr<CompositorAnimation>> result; |
| 1037 // Set player plaback rate also | 1044 // Set player plaback rate also |
| 1038 getAnimationOnCompositor(m_timing, *effect, result, -1.5); | 1045 getAnimationOnCompositor(m_timing, *effect, result, -1.5); |
| 1039 EXPECT_EQ(1U, result.size()); | 1046 EXPECT_EQ(1U, result.size()); |
| 1040 result[0].clear(); | 1047 result[0].clear(); |
| 1041 } | 1048 } |
| 1042 | 1049 |
| 1043 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationFillModeNo
ne) | 1050 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationFillModeNo
ne) |
| 1044 { | 1051 { |
| 1045 // KeyframeEffect to convert | 1052 // KeyframeEffect to convert |
| 1046 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel( | 1053 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel( |
| 1047 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
).get(), 0), | 1054 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
).get(), 0), |
| 1048 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
).get(), 1.0)); | 1055 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
).get(), 1.0)); |
| 1049 | 1056 |
| 1050 m_timing.fillMode = Timing::FillModeNone; | 1057 m_timing.fillMode = Timing::FillModeNone; |
| 1051 | 1058 |
| 1052 // Curve is created | 1059 // Curve is created |
| 1053 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; | 1060 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; |
| 1054 ExpectationSet usesMockCurve; | 1061 ExpectationSet usesMockCurve; |
| 1055 EXPECT_CALL(m_mockCompositor, createFloatAnimationCurve()) | 1062 EXPECT_CALL(*m_mockCompositorFactory, createFloatAnimationCurve()) |
| 1056 .WillOnce(Return(mockCurvePtr)); | 1063 .WillOnce(Return(mockCurvePtr)); |
| 1057 | 1064 |
| 1058 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(0.0, 2.0),
WebCompositorAnimationCurve::TimingFunctionTypeLinear)); | 1065 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(CompositorFloatKeyframe(0.0,
2.0), CompositorAnimationCurve::TimingFunctionTypeLinear)); |
| 1059 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(1.0, 5.0)))
; | 1066 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(CompositorFloatKeyframe(1.0,
5.0))); |
| 1060 | 1067 |
| 1061 // Create animation | 1068 // Create animation |
| 1062 WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMoc
k(WebCompositorAnimation::TargetPropertyOpacity); | 1069 WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMoc
k(CompositorAnimation::TargetPropertyOpacity); |
| 1063 ExpectationSet usesMockAnimation; | 1070 ExpectationSet usesMockAnimation; |
| 1064 | 1071 |
| 1065 usesMockCurve += EXPECT_CALL(m_mockCompositor, createAnimation(Ref(*mockCurv
ePtr), WebCompositorAnimation::TargetPropertyOpacity, _, _)) | 1072 usesMockCurve += EXPECT_CALL(*m_mockCompositorFactory, createAnimation(Ref(*
mockCurvePtr), CompositorAnimation::TargetPropertyOpacity, _, _)) |
| 1066 .WillOnce(Return(mockAnimationPtr)); | 1073 .WillOnce(Return(mockAnimationPtr)); |
| 1067 | 1074 |
| 1068 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(1)); | 1075 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(1)); |
| 1069 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(0.0)); | 1076 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(0.0)); |
| 1070 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setDirection(WebComposit
orAnimation::DirectionNormal)); | 1077 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setDirection(CompositorA
nimation::DirectionNormal)); |
| 1071 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setPlaybackRate(1)); | 1078 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setPlaybackRate(1)); |
| 1072 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setFillMode(WebComposito
rAnimation::FillModeNone)); | 1079 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setFillMode(CompositorAn
imation::FillModeNone)); |
| 1073 | 1080 |
| 1074 EXPECT_CALL(*mockAnimationPtr, delete_()) | 1081 EXPECT_CALL(*mockAnimationPtr, delete_()) |
| 1075 .Times(1) | 1082 .Times(1) |
| 1076 .After(usesMockAnimation); | 1083 .After(usesMockAnimation); |
| 1077 EXPECT_CALL(*mockCurvePtr, delete_()) | 1084 EXPECT_CALL(*mockCurvePtr, delete_()) |
| 1078 .Times(1) | 1085 .Times(1) |
| 1079 .After(usesMockCurve); | 1086 .After(usesMockCurve); |
| 1080 | 1087 |
| 1081 // Go! | 1088 // Go! |
| 1082 Vector<OwnPtr<WebCompositorAnimation>> result; | 1089 Vector<OwnPtr<CompositorAnimation>> result; |
| 1083 getAnimationOnCompositor(m_timing, *effect, result); | 1090 getAnimationOnCompositor(m_timing, *effect, result); |
| 1084 EXPECT_EQ(1U, result.size()); | 1091 EXPECT_EQ(1U, result.size()); |
| 1085 result[0].clear(); | 1092 result[0].clear(); |
| 1086 } | 1093 } |
| 1087 | 1094 |
| 1088 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationFillModeAu
to) | 1095 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationFillModeAu
to) |
| 1089 { | 1096 { |
| 1090 // KeyframeEffect to convert | 1097 // KeyframeEffect to convert |
| 1091 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel( | 1098 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel( |
| 1092 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
).get(), 0), | 1099 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
).get(), 0), |
| 1093 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
).get(), 1.0)); | 1100 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
).get(), 1.0)); |
| 1094 | 1101 |
| 1095 m_timing.fillMode = Timing::FillModeAuto; | 1102 m_timing.fillMode = Timing::FillModeAuto; |
| 1096 | 1103 |
| 1097 // Curve is created | 1104 // Curve is created |
| 1098 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; | 1105 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; |
| 1099 ExpectationSet usesMockCurve; | 1106 ExpectationSet usesMockCurve; |
| 1100 EXPECT_CALL(m_mockCompositor, createFloatAnimationCurve()) | 1107 EXPECT_CALL(*m_mockCompositorFactory, createFloatAnimationCurve()) |
| 1101 .WillOnce(Return(mockCurvePtr)); | 1108 .WillOnce(Return(mockCurvePtr)); |
| 1102 | 1109 |
| 1103 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(0.0, 2.0),
WebCompositorAnimationCurve::TimingFunctionTypeLinear)); | 1110 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(CompositorFloatKeyframe(0.0,
2.0), CompositorAnimationCurve::TimingFunctionTypeLinear)); |
| 1104 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(1.0, 5.0)))
; | 1111 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(CompositorFloatKeyframe(1.0,
5.0))); |
| 1105 | 1112 |
| 1106 // Create animation | 1113 // Create animation |
| 1107 WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMoc
k(WebCompositorAnimation::TargetPropertyOpacity); | 1114 WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMoc
k(CompositorAnimation::TargetPropertyOpacity); |
| 1108 ExpectationSet usesMockAnimation; | 1115 ExpectationSet usesMockAnimation; |
| 1109 | 1116 |
| 1110 usesMockCurve += EXPECT_CALL(m_mockCompositor, createAnimation(Ref(*mockCurv
ePtr), WebCompositorAnimation::TargetPropertyOpacity, _, _)) | 1117 usesMockCurve += EXPECT_CALL(*m_mockCompositorFactory, createAnimation(Ref(*
mockCurvePtr), CompositorAnimation::TargetPropertyOpacity, _, _)) |
| 1111 .WillOnce(Return(mockAnimationPtr)); | 1118 .WillOnce(Return(mockAnimationPtr)); |
| 1112 | 1119 |
| 1113 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(1)); | 1120 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(1)); |
| 1114 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(0.0)); | 1121 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(0.0)); |
| 1115 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setDirection(WebComposit
orAnimation::DirectionNormal)); | 1122 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setDirection(CompositorA
nimation::DirectionNormal)); |
| 1116 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setPlaybackRate(1)); | 1123 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setPlaybackRate(1)); |
| 1117 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setFillMode(WebComposito
rAnimation::FillModeNone)); | 1124 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setFillMode(CompositorAn
imation::FillModeNone)); |
| 1118 | 1125 |
| 1119 EXPECT_CALL(*mockAnimationPtr, delete_()) | 1126 EXPECT_CALL(*mockAnimationPtr, delete_()) |
| 1120 .Times(1) | 1127 .Times(1) |
| 1121 .After(usesMockAnimation); | 1128 .After(usesMockAnimation); |
| 1122 EXPECT_CALL(*mockCurvePtr, delete_()) | 1129 EXPECT_CALL(*mockCurvePtr, delete_()) |
| 1123 .Times(1) | 1130 .Times(1) |
| 1124 .After(usesMockCurve); | 1131 .After(usesMockCurve); |
| 1125 | 1132 |
| 1126 // Go! | 1133 // Go! |
| 1127 Vector<OwnPtr<WebCompositorAnimation>> result; | 1134 Vector<OwnPtr<CompositorAnimation>> result; |
| 1128 getAnimationOnCompositor(m_timing, *effect, result); | 1135 getAnimationOnCompositor(m_timing, *effect, result); |
| 1129 EXPECT_EQ(1U, result.size()); | 1136 EXPECT_EQ(1U, result.size()); |
| 1130 result[0].clear(); | 1137 result[0].clear(); |
| 1131 } | 1138 } |
| 1132 | 1139 |
| 1133 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationWithTiming
Function) | 1140 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationWithTiming
Function) |
| 1134 { | 1141 { |
| 1135 // KeyframeEffect to convert | 1142 // KeyframeEffect to convert |
| 1136 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel( | 1143 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel( |
| 1137 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
).get(), 0), | 1144 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
).get(), 0), |
| 1138 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
).get(), 1.0)); | 1145 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
).get(), 1.0)); |
| 1139 | 1146 |
| 1140 m_timing.timingFunction = m_cubicCustomTimingFunction; | 1147 m_timing.timingFunction = m_cubicCustomTimingFunction; |
| 1141 | 1148 |
| 1142 // Curve is created | 1149 // Curve is created |
| 1143 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; | 1150 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; |
| 1144 ExpectationSet usesMockCurve; | 1151 ExpectationSet usesMockCurve; |
| 1145 EXPECT_CALL(m_mockCompositor, createFloatAnimationCurve()) | 1152 EXPECT_CALL(*m_mockCompositorFactory, createFloatAnimationCurve()) |
| 1146 .WillOnce(Return(mockCurvePtr)); | 1153 .WillOnce(Return(mockCurvePtr)); |
| 1147 | 1154 |
| 1148 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(0.0, 2.0),
WebCompositorAnimationCurve::TimingFunctionTypeLinear)); | 1155 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(CompositorFloatKeyframe(0.0,
2.0), CompositorAnimationCurve::TimingFunctionTypeLinear)); |
| 1149 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(1.0, 5.0)))
; | 1156 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(CompositorFloatKeyframe(1.0,
5.0))); |
| 1150 usesMockCurve += EXPECT_CALL(*mockCurvePtr, setCubicBezierTimingFunction(1,
2, 3, 4)); | 1157 usesMockCurve += EXPECT_CALL(*mockCurvePtr, setCubicBezierTimingFunction(1,
2, 3, 4)); |
| 1151 | 1158 |
| 1152 // Create animation | 1159 // Create animation |
| 1153 WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMoc
k(WebCompositorAnimation::TargetPropertyOpacity); | 1160 WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMoc
k(CompositorAnimation::TargetPropertyOpacity); |
| 1154 ExpectationSet usesMockAnimation; | 1161 ExpectationSet usesMockAnimation; |
| 1155 | 1162 |
| 1156 usesMockCurve += EXPECT_CALL(m_mockCompositor, createAnimation(Ref(*mockCurv
ePtr), WebCompositorAnimation::TargetPropertyOpacity, _, _)) | 1163 usesMockCurve += EXPECT_CALL(*m_mockCompositorFactory, createAnimation(Ref(*
mockCurvePtr), CompositorAnimation::TargetPropertyOpacity, _, _)) |
| 1157 .WillOnce(Return(mockAnimationPtr)); | 1164 .WillOnce(Return(mockAnimationPtr)); |
| 1158 | 1165 |
| 1159 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(1)); | 1166 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(1)); |
| 1160 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(0.0)); | 1167 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(0.0)); |
| 1161 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setDirection(WebComposit
orAnimation::DirectionNormal)); | 1168 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setDirection(CompositorA
nimation::DirectionNormal)); |
| 1162 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setPlaybackRate(1)); | 1169 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setPlaybackRate(1)); |
| 1163 | 1170 |
| 1164 EXPECT_CALL(*mockAnimationPtr, delete_()) | 1171 EXPECT_CALL(*mockAnimationPtr, delete_()) |
| 1165 .Times(1) | 1172 .Times(1) |
| 1166 .After(usesMockAnimation); | 1173 .After(usesMockAnimation); |
| 1167 EXPECT_CALL(*mockCurvePtr, delete_()) | 1174 EXPECT_CALL(*mockCurvePtr, delete_()) |
| 1168 .Times(1) | 1175 .Times(1) |
| 1169 .After(usesMockCurve); | 1176 .After(usesMockCurve); |
| 1170 | 1177 |
| 1171 // Go! | 1178 // Go! |
| 1172 Vector<OwnPtr<WebCompositorAnimation>> result; | 1179 Vector<OwnPtr<CompositorAnimation>> result; |
| 1173 getAnimationOnCompositor(m_timing, *effect, result); | 1180 getAnimationOnCompositor(m_timing, *effect, result); |
| 1174 EXPECT_EQ(1U, result.size()); | 1181 EXPECT_EQ(1U, result.size()); |
| 1175 result[0].clear(); | 1182 result[0].clear(); |
| 1176 } | 1183 } |
| 1177 | 1184 |
| 1178 TEST_F(AnimationCompositorAnimationsTest, CancelIncompatibleCompositorAnimations
) | 1185 TEST_F(AnimationCompositorAnimationsTest, CancelIncompatibleCompositorAnimations
) |
| 1179 { | 1186 { |
| 1180 RefPtrWillBePersistent<Element> element = m_document->createElement("shared"
, ASSERT_NO_EXCEPTION); | 1187 RefPtrWillBePersistent<Element> element = m_document->createElement("shared"
, ASSERT_NO_EXCEPTION); |
| 1181 | 1188 |
| 1182 LayoutObjectProxy* layoutObject = LayoutObjectProxy::create(element.get()); | 1189 LayoutObjectProxy* layoutObject = LayoutObjectProxy::create(element.get()); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1219 simulateFrame(1.); | 1226 simulateFrame(1.); |
| 1220 | 1227 |
| 1221 element->setLayoutObject(nullptr); | 1228 element->setLayoutObject(nullptr); |
| 1222 LayoutObjectProxy::dispose(layoutObject); | 1229 LayoutObjectProxy::dispose(layoutObject); |
| 1223 | 1230 |
| 1224 Heap::collectAllGarbage(); | 1231 Heap::collectAllGarbage(); |
| 1225 EXPECT_TRUE(element->elementAnimations()->animations().isEmpty()); | 1232 EXPECT_TRUE(element->elementAnimations()->animations().isEmpty()); |
| 1226 } | 1233 } |
| 1227 | 1234 |
| 1228 } // namespace blink | 1235 } // namespace blink |
| OLD | NEW |