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 16 matching lines...) Expand all Loading... | |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 | 31 |
32 #include "core/animation/CompositorAnimations.h" | 32 #include "core/animation/CompositorAnimations.h" |
33 | 33 |
34 #include "core/animation/Animation.h" | 34 #include "core/animation/Animation.h" |
35 #include "core/animation/AnimationTimeline.h" | 35 #include "core/animation/AnimationTimeline.h" |
36 #include "core/animation/CompositorAnimationsImpl.h" | 36 #include "core/animation/CompositorAnimationsImpl.h" |
37 #include "core/animation/CompositorAnimationsTestHelper.h" | |
38 #include "core/animation/CompositorPendingAnimations.h" | 37 #include "core/animation/CompositorPendingAnimations.h" |
39 #include "core/animation/ElementAnimations.h" | 38 #include "core/animation/ElementAnimations.h" |
40 #include "core/animation/KeyframeEffect.h" | 39 #include "core/animation/KeyframeEffect.h" |
41 #include "core/animation/animatable/AnimatableDouble.h" | 40 #include "core/animation/animatable/AnimatableDouble.h" |
42 #include "core/animation/animatable/AnimatableFilterOperations.h" | 41 #include "core/animation/animatable/AnimatableFilterOperations.h" |
43 #include "core/animation/animatable/AnimatableTransform.h" | 42 #include "core/animation/animatable/AnimatableTransform.h" |
44 #include "core/animation/animatable/AnimatableValueTestHelper.h" | 43 #include "core/animation/animatable/AnimatableValueTestHelper.h" |
45 #include "core/dom/Document.h" | 44 #include "core/dom/Document.h" |
46 #include "core/layout/LayoutObject.h" | 45 #include "core/layout/LayoutObject.h" |
47 #include "core/testing/DummyPageHolder.h" | 46 #include "core/testing/DummyPageHolder.h" |
48 #include "platform/animation/CompositorAnimation.h" | 47 #include "platform/animation/CompositorAnimation.h" |
48 #include "platform/animation/CompositorFloatAnimationCurve.h" | |
49 #include "platform/animation/CompositorFloatKeyframe.h" | |
49 #include "platform/geometry/FloatBox.h" | 50 #include "platform/geometry/FloatBox.h" |
50 #include "platform/geometry/IntSize.h" | 51 #include "platform/geometry/IntSize.h" |
51 #include "platform/graphics/filters/FilterOperations.h" | 52 #include "platform/graphics/filters/FilterOperations.h" |
52 #include "platform/transforms/TransformOperations.h" | 53 #include "platform/transforms/TransformOperations.h" |
53 #include "platform/transforms/TranslateTransformOperation.h" | 54 #include "platform/transforms/TranslateTransformOperation.h" |
54 #include "testing/gmock/include/gmock/gmock.h" | |
55 #include "testing/gtest/include/gtest/gtest.h" | 55 #include "testing/gtest/include/gtest/gtest.h" |
56 #include "wtf/HashFunctions.h" | 56 #include "wtf/HashFunctions.h" |
57 #include "wtf/OwnPtr.h" | 57 #include "wtf/OwnPtr.h" |
58 #include "wtf/PassOwnPtr.h" | 58 #include "wtf/PassOwnPtr.h" |
59 #include "wtf/PassRefPtr.h" | 59 #include "wtf/PassRefPtr.h" |
60 #include "wtf/RefPtr.h" | 60 #include "wtf/RefPtr.h" |
61 | 61 |
62 namespace blink { | 62 namespace blink { |
63 | 63 |
64 using ::testing::ExpectationSet; | 64 class AnimationCompositorAnimationsTest : public ::testing::Test { |
65 using ::testing::Ref; | |
66 using ::testing::Return; | |
67 using ::testing::_; | |
68 | |
69 class AnimationCompositorAnimationsTest : public AnimationCompositorAnimationsTe stBase { | |
70 protected: | 65 protected: |
71 RefPtr<TimingFunction> m_linearTimingFunction; | 66 RefPtr<TimingFunction> m_linearTimingFunction; |
72 RefPtr<TimingFunction> m_cubicEaseTimingFunction; | 67 RefPtr<TimingFunction> m_cubicEaseTimingFunction; |
73 RefPtr<TimingFunction> m_cubicCustomTimingFunction; | 68 RefPtr<TimingFunction> m_cubicCustomTimingFunction; |
74 RefPtr<TimingFunction> m_stepTimingFunction; | 69 RefPtr<TimingFunction> m_stepTimingFunction; |
75 | 70 |
76 Timing m_timing; | 71 Timing m_timing; |
77 CompositorAnimationsImpl::CompositorTiming m_compositorTiming; | 72 CompositorAnimationsImpl::CompositorTiming m_compositorTiming; |
78 OwnPtr<AnimatableValueKeyframeVector> m_keyframeVector2; | 73 OwnPtr<AnimatableValueKeyframeVector> m_keyframeVector2; |
79 Persistent<AnimatableValueKeyframeEffectModel> m_keyframeAnimationEffect2; | 74 Persistent<AnimatableValueKeyframeEffectModel> m_keyframeAnimationEffect2; |
80 OwnPtr<AnimatableValueKeyframeVector> m_keyframeVector5; | 75 OwnPtr<AnimatableValueKeyframeVector> m_keyframeVector5; |
81 Persistent<AnimatableValueKeyframeEffectModel> m_keyframeAnimationEffect5; | 76 Persistent<AnimatableValueKeyframeEffectModel> m_keyframeAnimationEffect5; |
82 | 77 |
83 Persistent<Document> m_document; | 78 Persistent<Document> m_document; |
84 Persistent<Element> m_element; | 79 Persistent<Element> m_element; |
85 Persistent<AnimationTimeline> m_timeline; | 80 Persistent<AnimationTimeline> m_timeline; |
86 OwnPtr<DummyPageHolder> m_pageHolder; | 81 OwnPtr<DummyPageHolder> m_pageHolder; |
87 CompositorFactoryMock* m_mockCompositorFactory; | |
88 | 82 |
89 void SetUp() override | 83 void SetUp() override |
90 { | 84 { |
91 AnimationCompositorAnimationsTestBase::SetUp(); | |
92 | |
93 m_mockCompositorFactory = new CompositorFactoryMock(); | |
94 CompositorFactory::initializeForTesting(adoptPtr(m_mockCompositorFactory )); | |
95 | |
96 m_linearTimingFunction = LinearTimingFunction::shared(); | 85 m_linearTimingFunction = LinearTimingFunction::shared(); |
97 m_cubicEaseTimingFunction = CubicBezierTimingFunction::preset(CubicBezie rTimingFunction::EaseType::EASE); | 86 m_cubicEaseTimingFunction = CubicBezierTimingFunction::preset(CubicBezie rTimingFunction::EaseType::EASE); |
98 m_cubicCustomTimingFunction = CubicBezierTimingFunction::create(1, 2, 3, 4); | 87 m_cubicCustomTimingFunction = CubicBezierTimingFunction::create(1, 2, 3, 4); |
99 m_stepTimingFunction = StepsTimingFunction::create(1, StepsTimingFunctio n::StepPosition::END); | 88 m_stepTimingFunction = StepsTimingFunction::create(1, StepsTimingFunctio n::StepPosition::END); |
100 | 89 |
101 m_timing = createCompositableTiming(); | 90 m_timing = createCompositableTiming(); |
102 m_compositorTiming = CompositorAnimationsImpl::CompositorTiming(); | 91 m_compositorTiming = CompositorAnimationsImpl::CompositorTiming(); |
103 // Make sure the CompositableTiming is really compositable, otherwise | 92 // Make sure the CompositableTiming is really compositable, otherwise |
104 // most other tests will fail. | 93 // most other tests will fail. |
105 ASSERT(convertTimingForCompositor(m_timing, m_compositorTiming)); | 94 ASSERT(convertTimingForCompositor(m_timing, m_compositorTiming)); |
106 | 95 |
107 m_keyframeVector2 = createCompositableFloatKeyframeVector(2); | 96 m_keyframeVector2 = createCompositableFloatKeyframeVector(2); |
108 m_keyframeAnimationEffect2 = AnimatableValueKeyframeEffectModel::create( *m_keyframeVector2); | 97 m_keyframeAnimationEffect2 = AnimatableValueKeyframeEffectModel::create( *m_keyframeVector2); |
109 | 98 |
110 m_keyframeVector5 = createCompositableFloatKeyframeVector(5); | 99 m_keyframeVector5 = createCompositableFloatKeyframeVector(5); |
111 m_keyframeAnimationEffect5 = AnimatableValueKeyframeEffectModel::create( *m_keyframeVector5); | 100 m_keyframeAnimationEffect5 = AnimatableValueKeyframeEffectModel::create( *m_keyframeVector5); |
112 | 101 |
113 EXPECT_CALL(*m_mockCompositorFactory, createAnimationTimeline()) | |
114 .WillOnce(Return(new WebCompositorAnimationTimelineMock())); | |
115 | |
116 m_pageHolder = DummyPageHolder::create(); | 102 m_pageHolder = DummyPageHolder::create(); |
117 m_document = &m_pageHolder->document(); | 103 m_document = &m_pageHolder->document(); |
118 m_document->animationClock().resetTimeForTesting(); | 104 m_document->animationClock().resetTimeForTesting(); |
119 | 105 |
120 EXPECT_CALL(*m_mockCompositorFactory, createAnimationTimeline()) | |
121 .WillOnce(Return(new WebCompositorAnimationTimelineMock())); | |
122 | |
123 m_timeline = AnimationTimeline::create(m_document.get()); | 106 m_timeline = AnimationTimeline::create(m_document.get()); |
124 m_timeline->resetForTesting(); | 107 m_timeline->resetForTesting(); |
125 m_element = m_document->createElement("test", ASSERT_NO_EXCEPTION); | 108 m_element = m_document->createElement("test", ASSERT_NO_EXCEPTION); |
126 } | 109 } |
127 | 110 |
128 void TearDown() override | |
129 { | |
130 m_mockCompositorFactory = nullptr; | |
131 CompositorFactory::shutdown(); | |
132 } | |
133 | |
134 public: | 111 public: |
135 bool convertTimingForCompositor(const Timing& t, CompositorAnimationsImpl::C ompositorTiming& out) | 112 bool convertTimingForCompositor(const Timing& t, CompositorAnimationsImpl::C ompositorTiming& out) |
136 { | 113 { |
137 return CompositorAnimationsImpl::convertTimingForCompositor(t, 0, out, 1 ); | 114 return CompositorAnimationsImpl::convertTimingForCompositor(t, 0, out, 1 ); |
138 } | 115 } |
139 bool isCandidateForAnimationOnCompositor(const Timing& timing, const EffectM odel& effect) | 116 bool isCandidateForAnimationOnCompositor(const Timing& timing, const EffectM odel& effect) |
140 { | 117 { |
141 return CompositorAnimations::instance()->isCandidateForAnimationOnCompos itor(timing, *m_element.get(), nullptr, effect, 1); | 118 return CompositorAnimations::instance()->isCandidateForAnimationOnCompos itor(timing, *m_element.get(), nullptr, effect, 1); |
142 } | 119 } |
143 void getAnimationOnCompositor(Timing& timing, AnimatableValueKeyframeEffectM odel& effect, Vector<OwnPtr<CompositorAnimation>>& animations) | 120 void getAnimationOnCompositor(Timing& timing, AnimatableValueKeyframeEffectM odel& effect, Vector<OwnPtr<CompositorAnimation>>& animations) |
144 { | 121 { |
145 return getAnimationOnCompositor(timing, effect, animations, 1); | 122 getAnimationOnCompositor(timing, effect, animations, 1); |
146 } | 123 } |
147 void getAnimationOnCompositor(Timing& timing, AnimatableValueKeyframeEffectM odel& effect, Vector<OwnPtr<CompositorAnimation>>& animations, double playerPlay backRate) | 124 void getAnimationOnCompositor(Timing& timing, AnimatableValueKeyframeEffectM odel& effect, Vector<OwnPtr<CompositorAnimation>>& animations, double playerPlay backRate) |
148 { | 125 { |
149 return CompositorAnimationsImpl::getAnimationOnCompositor(timing, 0, std ::numeric_limits<double>::quiet_NaN(), 0, effect, animations, playerPlaybackRate ); | 126 CompositorAnimationsImpl::getAnimationOnCompositor(timing, 0, std::numer ic_limits<double>::quiet_NaN(), 0, effect, animations, playerPlaybackRate); |
150 } | 127 } |
151 bool getAnimationBounds(FloatBox& boundingBox, const EffectModel& effect, do uble minValue, double maxValue) | 128 bool getAnimationBounds(FloatBox& boundingBox, const EffectModel& effect, do uble minValue, double maxValue) |
152 { | 129 { |
153 return CompositorAnimations::instance()->getAnimatedBoundingBox(bounding Box, effect, minValue, maxValue); | 130 return CompositorAnimations::instance()->getAnimatedBoundingBox(bounding Box, effect, minValue, maxValue); |
154 } | 131 } |
155 | 132 |
156 bool duplicateSingleKeyframeAndTestIsCandidateOnResult(AnimatableValueKeyfra me* frame) | 133 bool duplicateSingleKeyframeAndTestIsCandidateOnResult(AnimatableValueKeyfra me* frame) |
157 { | 134 { |
158 EXPECT_EQ(frame->offset(), 0); | 135 EXPECT_EQ(frame->offset(), 0); |
159 AnimatableValueKeyframeVector frames; | 136 AnimatableValueKeyframeVector frames; |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
263 } | 240 } |
264 return nullptr; | 241 return nullptr; |
265 } | 242 } |
266 | 243 |
267 void simulateFrame(double time) | 244 void simulateFrame(double time) |
268 { | 245 { |
269 m_document->animationClock().updateTime(time); | 246 m_document->animationClock().updateTime(time); |
270 m_document->compositorPendingAnimations().update(false); | 247 m_document->compositorPendingAnimations().update(false); |
271 m_timeline->serviceAnimations(TimingUpdateForAnimationFrame); | 248 m_timeline->serviceAnimations(TimingUpdateForAnimationFrame); |
272 } | 249 } |
250 | |
251 PassOwnPtr<CompositorAnimation> convertToCompositorAnimation(AnimatableValue KeyframeEffectModel& effect, double playerPlaybackRate) | |
252 { | |
253 Vector<OwnPtr<CompositorAnimation>> result; | |
254 getAnimationOnCompositor(m_timing, effect, result, playerPlaybackRate); | |
255 DCHECK_EQ(1U, result.size()); | |
256 return adoptPtr(result[0].leakPtr()); | |
257 } | |
258 | |
259 PassOwnPtr<CompositorAnimation> convertToCompositorAnimation(AnimatableValue KeyframeEffectModel& effect) | |
260 { | |
261 return convertToCompositorAnimation(effect, 1.0); | |
262 } | |
273 }; | 263 }; |
274 | 264 |
275 class LayoutObjectProxy : public LayoutObject { | 265 class LayoutObjectProxy : public LayoutObject { |
276 public: | 266 public: |
277 static LayoutObjectProxy* create(Node* node) | 267 static LayoutObjectProxy* create(Node* node) |
278 { | 268 { |
279 return new LayoutObjectProxy(node); | 269 return new LayoutObjectProxy(node); |
280 } | 270 } |
281 | 271 |
282 static void dispose(LayoutObjectProxy* proxy) | 272 static void dispose(LayoutObjectProxy* proxy) |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
649 | 639 |
650 // ----------------------------------------------------------------------- | 640 // ----------------------------------------------------------------------- |
651 // ----------------------------------------------------------------------- | 641 // ----------------------------------------------------------------------- |
652 | 642 |
653 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimation) | 643 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimation) |
654 { | 644 { |
655 // KeyframeEffect to convert | 645 // KeyframeEffect to convert |
656 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel( | 646 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel( |
657 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0 ).get(), 0), | 647 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0 ).get(), 0), |
658 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0 ).get(), 1.0)); | 648 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0 ).get(), 1.0)); |
659 // -- | |
660 | 649 |
661 // Curve is created | 650 OwnPtr<CompositorAnimation> animation = convertToCompositorAnimation(*effect ); |
662 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; | 651 EXPECT_EQ(CompositorTargetProperty::OPACITY, animation->targetProperty()); |
663 ExpectationSet usesMockCurve; | 652 EXPECT_EQ(1.0, animation->iterations()); |
664 EXPECT_CALL(*m_mockCompositorFactory, createFloatAnimationCurve()) | 653 EXPECT_EQ(0, animation->timeOffset()); |
665 .WillOnce(Return(mockCurvePtr)); | 654 EXPECT_EQ(CompositorAnimation::Direction::NORMAL, animation->getDirection()) ; |
655 EXPECT_EQ(1.0, animation->playbackRate()); | |
666 | 656 |
667 usesMockCurve += EXPECT_CALL(*mockCurvePtr, addLinearKeyframe(CompositorFloa tKeyframe(0.0, 2.0))); | 657 OwnPtr<CompositorFloatAnimationCurve> keyframedFloatCurve = animation->float CurveForTesting(); |
668 usesMockCurve += EXPECT_CALL(*mockCurvePtr, addCubicBezierKeyframe(Composito rFloatKeyframe(1.0, 5.0), CubicBezierTimingFunction::EaseType::EASE)); | |
669 | 658 |
670 // Create animation | 659 Vector<CompositorFloatKeyframe> keyframes = keyframedFloatCurve->keyframesFo rTesting(); |
671 WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMoc k(CompositorTargetProperty::OPACITY); | 660 ASSERT_EQ(2UL, keyframes.size()); |
672 ExpectationSet usesMockAnimation; | |
673 | 661 |
674 usesMockCurve += EXPECT_CALL(*m_mockCompositorFactory, createAnimation(Ref(* mockCurvePtr), CompositorTargetProperty::OPACITY, _, _)) | 662 EXPECT_EQ(0, keyframes[0].time); |
675 .WillOnce(Return(mockAnimationPtr)); | 663 EXPECT_EQ(2.0f, keyframes[0].value); |
676 | 664 |
677 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(1)); | 665 EXPECT_EQ(1.0, keyframes[1].time); |
678 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(0.0)); | 666 EXPECT_EQ(5.0f, keyframes[1].value); |
679 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setDirection(CompositorA nimation::Direction::NORMAL)); | |
680 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setPlaybackRate(1)); | |
681 | 667 |
682 EXPECT_CALL(*mockAnimationPtr, delete_()) | 668 EXPECT_EQ(CubicBezierTimingFunction::EaseType::EASE, keyframedFloatCurve->ge tKeyframeEaseTypeForTesting(1)); |
alancutter (OOO until 2018)
2016/06/01 02:20:55
We should continue to test that the first keyframe
| |
683 .Times(1) | |
684 .After(usesMockAnimation); | |
685 EXPECT_CALL(*mockCurvePtr, delete_()) | |
686 .Times(1) | |
687 .After(usesMockCurve); | |
688 | |
689 // Go! | |
690 Vector<OwnPtr<CompositorAnimation>> result; | |
691 getAnimationOnCompositor(m_timing, *effect, result); | |
692 EXPECT_EQ(1U, result.size()); | |
693 result[0].reset(); | |
694 } | 669 } |
695 | 670 |
696 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationDuration) | 671 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationDuration) |
697 { | 672 { |
698 // KeyframeEffect to convert | 673 // KeyframeEffect to convert |
699 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel( | 674 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel( |
700 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0 ).get(), 0), | 675 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0 ).get(), 0), |
701 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0 ).get(), 1.0)); | 676 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0 ).get(), 1.0)); |
702 | 677 |
703 m_timing.iterationDuration = 10.0; | 678 const double duration = 10.0; |
704 // -- | 679 m_timing.iterationDuration = duration; |
705 | 680 |
706 // Curve is created | 681 OwnPtr<CompositorAnimation> animation = convertToCompositorAnimation(*effect ); |
707 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; | 682 OwnPtr<CompositorFloatAnimationCurve> keyframedFloatCurve = animation->float CurveForTesting(); |
708 ExpectationSet usesMockCurve; | |
709 EXPECT_CALL(*m_mockCompositorFactory, createFloatAnimationCurve()) | |
710 .WillOnce(Return(mockCurvePtr)); | |
711 | 683 |
712 usesMockCurve += EXPECT_CALL(*mockCurvePtr, addLinearKeyframe(CompositorFloa tKeyframe(0.0, 2.0))); | 684 Vector<CompositorFloatKeyframe> keyframes = keyframedFloatCurve->keyframesFo rTesting(); |
713 usesMockCurve += EXPECT_CALL(*mockCurvePtr, addCubicBezierKeyframe(Composito rFloatKeyframe(10.0, 5.0), CubicBezierTimingFunction::EaseType::EASE)); | 685 ASSERT_EQ(2UL, keyframes.size()); |
714 | 686 |
715 // Create animation | 687 EXPECT_EQ(duration, keyframes[1].time); |
716 WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMoc k(CompositorTargetProperty::OPACITY); | |
717 ExpectationSet usesMockAnimation; | |
718 | |
719 usesMockCurve += EXPECT_CALL(*m_mockCompositorFactory, createAnimation(Ref(* mockCurvePtr), CompositorTargetProperty::OPACITY, _, _)) | |
720 .WillOnce(Return(mockAnimationPtr)); | |
721 | |
722 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(1)); | |
723 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(0.0)); | |
724 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setDirection(CompositorA nimation::Direction::NORMAL)); | |
725 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setPlaybackRate(1)); | |
726 | |
727 EXPECT_CALL(*mockAnimationPtr, delete_()) | |
728 .Times(1) | |
729 .After(usesMockAnimation); | |
730 EXPECT_CALL(*mockCurvePtr, delete_()) | |
731 .Times(1) | |
732 .After(usesMockCurve); | |
733 | |
734 // Go! | |
735 Vector<OwnPtr<CompositorAnimation>> result; | |
736 getAnimationOnCompositor(m_timing, *effect, result); | |
737 EXPECT_EQ(1U, result.size()); | |
738 result[0].reset(); | |
739 } | 688 } |
740 | 689 |
741 TEST_F(AnimationCompositorAnimationsTest, createMultipleKeyframeOpacityAnimation Linear) | 690 TEST_F(AnimationCompositorAnimationsTest, createMultipleKeyframeOpacityAnimation Linear) |
742 { | 691 { |
743 // KeyframeEffect to convert | 692 // KeyframeEffect to convert |
744 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel( | 693 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel( |
745 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0 ).get(), 0), | 694 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0 ).get(), 0), |
746 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(-1. 0).get(), 0.25), | 695 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(-1. 0).get(), 0.25), |
747 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(20. 0).get(), 0.5), | 696 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(20. 0).get(), 0.5), |
748 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0 ).get(), 1.0)); | 697 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0 ).get(), 1.0)); |
749 | 698 |
750 m_timing.iterationCount = 5; | 699 m_timing.iterationCount = 5; |
751 m_timing.direction = Timing::PlaybackDirectionAlternate; | 700 m_timing.direction = Timing::PlaybackDirectionAlternate; |
752 m_timing.playbackRate = 2.0; | 701 m_timing.playbackRate = 2.0; |
753 // -- | |
754 | 702 |
755 // Curve is created | 703 OwnPtr<CompositorAnimation> animation = convertToCompositorAnimation(*effect ); |
756 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock(); | 704 EXPECT_EQ(CompositorTargetProperty::OPACITY, animation->targetProperty()); |
757 ExpectationSet usesMockCurve; | 705 EXPECT_EQ(5.0, animation->iterations()); |
706 EXPECT_EQ(0, animation->timeOffset()); | |
707 EXPECT_EQ(CompositorAnimation::Direction::ALTERNATE_NORMAL, animation->getDi rection()); | |
708 EXPECT_EQ(2.0, animation->playbackRate()); | |
758 | 709 |
759 EXPECT_CALL(*m_mockCompositorFactory, createFloatAnimationCurve()) | 710 OwnPtr<CompositorFloatAnimationCurve> keyframedFloatCurve = animation->float CurveForTesting(); |
760 .WillOnce(Return(mockCurvePtr)); | |
761 | 711 |
762 usesMockCurve += EXPECT_CALL(*mockCurvePtr, addLinearKeyframe(CompositorFloa tKeyframe(0.0, 2.0))); | 712 Vector<CompositorFloatKeyframe> keyframes = keyframedFloatCurve->keyframesFo rTesting(); |
763 usesMockCurve += EXPECT_CALL(*mockCurvePtr, addLinearKeyframe(CompositorFloa tKeyframe(0.25, -1.0))); | 713 ASSERT_EQ(4UL, keyframes.size()); |
764 usesMockCurve += EXPECT_CALL(*mockCurvePtr, addLinearKeyframe(CompositorFloa tKeyframe(0.5, 20.0))); | |
765 usesMockCurve += EXPECT_CALL(*mockCurvePtr, addCubicBezierKeyframe(Composito rFloatKeyframe(1.0, 5.0), CubicBezierTimingFunction::EaseType::EASE)); | |
766 | 714 |
767 // KeyframeEffect is created | 715 EXPECT_EQ(0, keyframes[0].time); |
768 WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMoc k(CompositorTargetProperty::OPACITY); | 716 EXPECT_EQ(2.0f, keyframes[0].value); |
769 ExpectationSet usesMockAnimation; | 717 EXPECT_TRUE(keyframedFloatCurve->keyframeHasLinearTimingFunctionForTesting(0 )); |
770 | 718 |
771 usesMockCurve += EXPECT_CALL(*m_mockCompositorFactory, createAnimation(Ref(* mockCurvePtr), CompositorTargetProperty::OPACITY, _, _)) | 719 EXPECT_EQ(0.25, keyframes[1].time); |
772 .WillOnce(Return(mockAnimationPtr)); | 720 EXPECT_EQ(-1.0f, keyframes[1].value); |
721 EXPECT_TRUE(keyframedFloatCurve->keyframeHasLinearTimingFunctionForTesting(1 )); | |
773 | 722 |
774 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(5)); | 723 EXPECT_EQ(0.5, keyframes[2].time); |
775 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(0.0)); | 724 EXPECT_EQ(20.0f, keyframes[2].value); |
776 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setDirection(CompositorA nimation::Direction::ALTERNATE_NORMAL)); | 725 EXPECT_TRUE(keyframedFloatCurve->keyframeHasLinearTimingFunctionForTesting(2 )); |
777 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setPlaybackRate(2.0)); | |
778 | 726 |
779 EXPECT_CALL(*mockAnimationPtr, delete_()) | 727 EXPECT_EQ(1.0, keyframes[3].time); |
780 .Times(1) | 728 EXPECT_EQ(5.0f, keyframes[3].value); |
781 .After(usesMockAnimation); | 729 EXPECT_EQ(CubicBezierTimingFunction::EaseType::EASE, keyframedFloatCurve->ge tKeyframeEaseTypeForTesting(3)); |
782 EXPECT_CALL(*mockCurvePtr, delete_()) | |
783 .Times(1) | |
784 .After(usesMockCurve); | |
785 | |
786 // Go! | |
787 Vector<OwnPtr<CompositorAnimation>> result; | |
788 getAnimationOnCompositor(m_timing, *effect, result); | |
789 EXPECT_EQ(1U, result.size()); | |
790 result[0].reset(); | |
791 } | 730 } |
792 | 731 |
793 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationStartDelay ) | 732 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationStartDelay ) |
794 { | 733 { |
795 // KeyframeEffect to convert | 734 // KeyframeEffect to convert |
796 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel( | 735 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel( |
797 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0 ).get(), 0), | 736 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0 ).get(), 0), |
798 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0 ).get(), 1.0)); | 737 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0 ).get(), 1.0)); |
799 | 738 |
739 const double startDelay = 3.25; | |
740 | |
800 m_timing.iterationCount = 5.0; | 741 m_timing.iterationCount = 5.0; |
801 m_timing.iterationDuration = 1.75; | 742 m_timing.iterationDuration = 1.75; |
802 m_timing.startDelay = 3.25; | 743 m_timing.startDelay = startDelay; |
803 // -- | |
804 | 744 |
805 // Curve is created | 745 OwnPtr<CompositorAnimation> animation = convertToCompositorAnimation(*effect ); |
806 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; | |
807 ExpectationSet usesMockCurve; | |
808 EXPECT_CALL(*m_mockCompositorFactory, createFloatAnimationCurve()) | |
809 .WillOnce(Return(mockCurvePtr)); | |
810 | 746 |
811 usesMockCurve += EXPECT_CALL(*mockCurvePtr, addLinearKeyframe(CompositorFloa tKeyframe(0.0, 2.0))); | 747 EXPECT_EQ(CompositorTargetProperty::OPACITY, animation->targetProperty()); |
812 usesMockCurve += EXPECT_CALL(*mockCurvePtr, addCubicBezierKeyframe(Composito rFloatKeyframe(1.75, 5.0), CubicBezierTimingFunction::EaseType::EASE)); | 748 EXPECT_EQ(5.0, animation->iterations()); |
749 EXPECT_EQ(-startDelay, animation->timeOffset()); | |
813 | 750 |
814 // Create animation | 751 OwnPtr<CompositorFloatAnimationCurve> keyframedFloatCurve = animation->float CurveForTesting(); |
815 WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMoc k(CompositorTargetProperty::OPACITY); | |
816 ExpectationSet usesMockAnimation; | |
817 | 752 |
818 usesMockCurve += EXPECT_CALL(*m_mockCompositorFactory, createAnimation(Ref(* mockCurvePtr), CompositorTargetProperty::OPACITY, _, _)) | 753 Vector<CompositorFloatKeyframe> keyframes = keyframedFloatCurve->keyframesFo rTesting(); |
819 .WillOnce(Return(mockAnimationPtr)); | 754 ASSERT_EQ(2UL, keyframes.size()); |
820 | 755 |
821 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(5)); | 756 EXPECT_EQ(1.75, keyframes[1].time); |
822 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(-3.25)); | 757 EXPECT_EQ(5.0f, keyframes[1].value); |
823 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setDirection(CompositorA nimation::Direction::NORMAL)); | |
824 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setPlaybackRate(1)); | |
825 | |
826 EXPECT_CALL(*mockAnimationPtr, delete_()) | |
827 .Times(1) | |
828 .After(usesMockAnimation); | |
829 EXPECT_CALL(*mockCurvePtr, delete_()) | |
830 .Times(1) | |
831 .After(usesMockCurve); | |
832 | |
833 // Go! | |
834 Vector<OwnPtr<CompositorAnimation>> result; | |
835 getAnimationOnCompositor(m_timing, *effect, result); | |
836 EXPECT_EQ(1U, result.size()); | |
837 result[0].reset(); | |
838 } | 758 } |
839 | 759 |
840 TEST_F(AnimationCompositorAnimationsTest, createMultipleKeyframeOpacityAnimation Chained) | 760 TEST_F(AnimationCompositorAnimationsTest, createMultipleKeyframeOpacityAnimation Chained) |
841 { | 761 { |
842 // KeyframeEffect to convert | 762 // KeyframeEffect to convert |
843 AnimatableValueKeyframeVector frames; | 763 AnimatableValueKeyframeVector frames; |
844 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble:: create(2.0).get(), 0)); | 764 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble:: create(2.0).get(), 0)); |
845 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble:: create(-1.0).get(), 0.25)); | 765 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble:: create(-1.0).get(), 0.25)); |
846 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble:: create(20.0).get(), 0.5)); | 766 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble:: create(20.0).get(), 0.5)); |
847 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble:: create(5.0).get(), 1.0)); | 767 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble:: create(5.0).get(), 1.0)); |
848 frames[0]->setEasing(m_cubicEaseTimingFunction.get()); | 768 frames[0]->setEasing(m_cubicEaseTimingFunction.get()); |
849 frames[1]->setEasing(m_linearTimingFunction.get()); | 769 frames[1]->setEasing(m_linearTimingFunction.get()); |
850 frames[2]->setEasing(m_cubicCustomTimingFunction.get()); | 770 frames[2]->setEasing(m_cubicCustomTimingFunction.get()); |
851 AnimatableValueKeyframeEffectModel* effect = AnimatableValueKeyframeEffectMo del::create(frames); | 771 AnimatableValueKeyframeEffectModel* effect = AnimatableValueKeyframeEffectMo del::create(frames); |
852 | 772 |
853 m_timing.timingFunction = m_linearTimingFunction.get(); | 773 m_timing.timingFunction = m_linearTimingFunction.get(); |
854 m_timing.iterationDuration = 2.0; | 774 m_timing.iterationDuration = 2.0; |
855 m_timing.iterationCount = 10; | 775 m_timing.iterationCount = 10; |
856 m_timing.direction = Timing::PlaybackDirectionAlternate; | 776 m_timing.direction = Timing::PlaybackDirectionAlternate; |
857 // -- | |
858 | 777 |
859 // Curve is created | 778 OwnPtr<CompositorAnimation> animation = convertToCompositorAnimation(*effect ); |
860 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock(); | 779 EXPECT_EQ(CompositorTargetProperty::OPACITY, animation->targetProperty()); |
861 ExpectationSet usesMockCurve; | 780 EXPECT_EQ(10.0, animation->iterations()); |
781 EXPECT_EQ(0, animation->timeOffset()); | |
782 EXPECT_EQ(CompositorAnimation::Direction::ALTERNATE_NORMAL, animation->getDi rection()); | |
783 EXPECT_EQ(1.0, animation->playbackRate()); | |
862 | 784 |
863 EXPECT_CALL(*m_mockCompositorFactory, createFloatAnimationCurve()) | 785 OwnPtr<CompositorFloatAnimationCurve> keyframedFloatCurve = animation->float CurveForTesting(); |
864 .WillOnce(Return(mockCurvePtr)); | |
865 | 786 |
866 usesMockCurve += EXPECT_CALL(*mockCurvePtr, addCubicBezierKeyframe(Composito rFloatKeyframe(0.0, 2.0), CubicBezierTimingFunction::EaseType::EASE)); | 787 Vector<CompositorFloatKeyframe> keyframes = keyframedFloatCurve->keyframesFo rTesting(); |
867 usesMockCurve += EXPECT_CALL(*mockCurvePtr, addLinearKeyframe(CompositorFloa tKeyframe(0.5, -1.0))); | 788 ASSERT_EQ(4UL, keyframes.size()); |
868 usesMockCurve += EXPECT_CALL(*mockCurvePtr, addCubicBezierKeyframe(Composito rFloatKeyframe(1.0, 20.0), 1.0, 2.0, 3.0, 4.0)); | |
869 usesMockCurve += EXPECT_CALL(*mockCurvePtr, addCubicBezierKeyframe(Composito rFloatKeyframe(2.0, 5.0), CubicBezierTimingFunction::EaseType::EASE)); | |
870 | 789 |
871 // KeyframeEffect is created | 790 EXPECT_EQ(0, keyframes[0].time); |
872 WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMoc k(CompositorTargetProperty::OPACITY); | 791 EXPECT_EQ(2.0f, keyframes[0].value); |
873 ExpectationSet usesMockAnimation; | 792 EXPECT_EQ(CubicBezierTimingFunction::EaseType::EASE, keyframedFloatCurve->ge tKeyframeEaseTypeForTesting(0)); |
874 | 793 |
875 usesMockCurve += EXPECT_CALL(*m_mockCompositorFactory, createAnimation(Ref(* mockCurvePtr), CompositorTargetProperty::OPACITY, _, _)) | 794 EXPECT_EQ(0.5, keyframes[1].time); |
876 .WillOnce(Return(mockAnimationPtr)); | 795 EXPECT_EQ(-1.0f, keyframes[1].value); |
796 EXPECT_TRUE(keyframedFloatCurve->keyframeHasLinearTimingFunctionForTesting(1 )); | |
877 | 797 |
878 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(10)); | 798 EXPECT_EQ(1.0, keyframes[2].time); |
879 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(0.0)); | 799 EXPECT_EQ(20.0f, keyframes[2].value); |
880 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setDirection(CompositorA nimation::Direction::ALTERNATE_NORMAL)); | 800 EXPECT_EQ(CubicBezierTimingFunction::EaseType::CUSTOM, keyframedFloatCurve-> getKeyframeEaseTypeForTesting(2)); |
881 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setPlaybackRate(1)); | |
882 | 801 |
883 EXPECT_CALL(*mockAnimationPtr, delete_()) | 802 EXPECT_EQ(2.0, keyframes[3].time); |
884 .Times(1) | 803 EXPECT_EQ(5.0f, keyframes[3].value); |
885 .After(usesMockAnimation); | 804 EXPECT_EQ(CubicBezierTimingFunction::EaseType::EASE, keyframedFloatCurve->ge tKeyframeEaseTypeForTesting(3)); |
886 EXPECT_CALL(*mockCurvePtr, delete_()) | |
887 .Times(1) | |
888 .After(usesMockCurve); | |
889 | |
890 // Go! | |
891 Vector<OwnPtr<CompositorAnimation>> result; | |
892 getAnimationOnCompositor(m_timing, *effect, result); | |
893 EXPECT_EQ(1U, result.size()); | |
894 result[0].reset(); | |
895 } | 805 } |
896 | 806 |
897 TEST_F(AnimationCompositorAnimationsTest, createReversedOpacityAnimation) | 807 TEST_F(AnimationCompositorAnimationsTest, createReversedOpacityAnimation) |
898 { | 808 { |
899 RefPtr<TimingFunction> cubicEasyFlipTimingFunction = CubicBezierTimingFuncti on::create(0.0, 0.0, 0.0, 1.0); | 809 RefPtr<TimingFunction> cubicEasyFlipTimingFunction = CubicBezierTimingFuncti on::create(0.0, 0.0, 0.0, 1.0); |
900 | 810 |
901 // KeyframeEffect to convert | 811 // KeyframeEffect to convert |
902 AnimatableValueKeyframeVector frames; | 812 AnimatableValueKeyframeVector frames; |
903 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble:: create(2.0).get(), 0)); | 813 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble:: create(2.0).get(), 0)); |
904 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble:: create(-1.0).get(), 0.25)); | 814 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble:: create(-1.0).get(), 0.25)); |
905 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble:: create(20.0).get(), 0.5)); | 815 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble:: create(20.0).get(), 0.5)); |
906 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble:: create(5.0).get(), 1.0)); | 816 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble:: create(5.0).get(), 1.0)); |
907 frames[0]->setEasing(CubicBezierTimingFunction::preset(CubicBezierTimingFunc tion::EaseType::EASE_IN)); | 817 frames[0]->setEasing(CubicBezierTimingFunction::preset(CubicBezierTimingFunc tion::EaseType::EASE_IN)); |
908 frames[1]->setEasing(m_linearTimingFunction.get()); | 818 frames[1]->setEasing(m_linearTimingFunction.get()); |
909 frames[2]->setEasing(cubicEasyFlipTimingFunction.get()); | 819 frames[2]->setEasing(cubicEasyFlipTimingFunction.get()); |
910 AnimatableValueKeyframeEffectModel* effect = AnimatableValueKeyframeEffectMo del::create(frames); | 820 AnimatableValueKeyframeEffectModel* effect = AnimatableValueKeyframeEffectMo del::create(frames); |
911 | 821 |
912 m_timing.timingFunction = m_linearTimingFunction.get(); | 822 m_timing.timingFunction = m_linearTimingFunction.get(); |
913 m_timing.iterationCount = 10; | 823 m_timing.iterationCount = 10; |
914 m_timing.direction = Timing::PlaybackDirectionAlternateReverse; | 824 m_timing.direction = Timing::PlaybackDirectionAlternateReverse; |
915 // -- | |
916 | 825 |
917 // Curve is created | 826 OwnPtr<CompositorAnimation> animation = convertToCompositorAnimation(*effect ); |
918 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock(); | 827 EXPECT_EQ(CompositorTargetProperty::OPACITY, animation->targetProperty()); |
919 ExpectationSet usesMockCurve; | 828 EXPECT_EQ(10.0, animation->iterations()); |
829 EXPECT_EQ(0, animation->timeOffset()); | |
830 EXPECT_EQ(CompositorAnimation::Direction::ALTERNATE_REVERSE, animation->getD irection()); | |
831 EXPECT_EQ(1.0, animation->playbackRate()); | |
920 | 832 |
921 EXPECT_CALL(*m_mockCompositorFactory, createFloatAnimationCurve()) | 833 OwnPtr<CompositorFloatAnimationCurve> keyframedFloatCurve = animation->float CurveForTesting(); |
922 .WillOnce(Return(mockCurvePtr)); | |
923 | 834 |
924 usesMockCurve += EXPECT_CALL(*mockCurvePtr, addCubicBezierKeyframe(Composito rFloatKeyframe(0.0, 2.0), CubicBezierTimingFunction::EaseType::EASE_IN)); | 835 Vector<CompositorFloatKeyframe> keyframes = keyframedFloatCurve->keyframesFo rTesting(); |
925 usesMockCurve += EXPECT_CALL(*mockCurvePtr, addLinearKeyframe(CompositorFloa tKeyframe(0.25, -1.0))); | 836 ASSERT_EQ(4UL, keyframes.size()); |
926 usesMockCurve += EXPECT_CALL(*mockCurvePtr, addCubicBezierKeyframe(Composito rFloatKeyframe(0.5, 20.0), 0.0, 0.0, 0.0, 1.0)); | |
927 usesMockCurve += EXPECT_CALL(*mockCurvePtr, addCubicBezierKeyframe(Composito rFloatKeyframe(1.0, 5.0), CubicBezierTimingFunction::EaseType::EASE)); | |
928 | 837 |
929 // Create the animation | 838 EXPECT_TRUE(keyframedFloatCurve->curveHasLinearTimingFunctionForTesting()); |
930 WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMoc k(CompositorTargetProperty::OPACITY); | |
931 ExpectationSet usesMockAnimation; | |
932 | 839 |
933 usesMockCurve += EXPECT_CALL(*m_mockCompositorFactory, createAnimation(Ref(* mockCurvePtr), CompositorTargetProperty::OPACITY, _, _)) | 840 EXPECT_EQ(0, keyframes[0].time); |
934 .WillOnce(Return(mockAnimationPtr)); | 841 EXPECT_EQ(2.0f, keyframes[0].value); |
842 EXPECT_EQ(CubicBezierTimingFunction::EaseType::EASE_IN, keyframedFloatCurve- >getKeyframeEaseTypeForTesting(0)); | |
935 | 843 |
936 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(10)); | 844 EXPECT_EQ(0.25, keyframes[1].time); |
937 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(0.0)); | 845 EXPECT_EQ(-1.0f, keyframes[1].value); |
938 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setDirection(CompositorA nimation::Direction::ALTERNATE_REVERSE)); | 846 EXPECT_TRUE(keyframedFloatCurve->keyframeHasLinearTimingFunctionForTesting(1 )); |
939 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setPlaybackRate(1)); | |
940 | 847 |
941 EXPECT_CALL(*mockAnimationPtr, delete_()) | 848 EXPECT_EQ(0.5, keyframes[2].time); |
942 .Times(1) | 849 EXPECT_EQ(20.0f, keyframes[2].value); |
943 .After(usesMockAnimation); | 850 EXPECT_EQ(CubicBezierTimingFunction::EaseType::CUSTOM, keyframedFloatCurve-> getKeyframeEaseTypeForTesting(2)); |
944 EXPECT_CALL(*mockCurvePtr, delete_()) | |
945 .Times(1) | |
946 .After(usesMockCurve); | |
947 | 851 |
948 // Go! | 852 EXPECT_EQ(1.0, keyframes[3].time); |
949 Vector<OwnPtr<CompositorAnimation>> result; | 853 EXPECT_EQ(5.0f, keyframes[3].value); |
950 getAnimationOnCompositor(m_timing, *effect, result); | 854 EXPECT_EQ(CubicBezierTimingFunction::EaseType::EASE, keyframedFloatCurve->ge tKeyframeEaseTypeForTesting(3)); |
951 EXPECT_EQ(1U, result.size()); | |
952 result[0].reset(); | |
953 } | 855 } |
954 | 856 |
955 TEST_F(AnimationCompositorAnimationsTest, createReversedOpacityAnimationNegative StartDelay) | 857 TEST_F(AnimationCompositorAnimationsTest, createReversedOpacityAnimationNegative StartDelay) |
956 { | 858 { |
957 // KeyframeEffect to convert | 859 // KeyframeEffect to convert |
958 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel( | 860 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel( |
959 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0 ).get(), 0), | 861 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0 ).get(), 0), |
960 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0 ).get(), 1.0)); | 862 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0 ).get(), 1.0)); |
961 | 863 |
864 const double negativeStartDelay = -3; | |
865 | |
962 m_timing.iterationCount = 5.0; | 866 m_timing.iterationCount = 5.0; |
963 m_timing.iterationDuration = 1.5; | 867 m_timing.iterationDuration = 1.5; |
964 m_timing.startDelay = -3; | 868 m_timing.startDelay = negativeStartDelay; |
965 m_timing.direction = Timing::PlaybackDirectionAlternateReverse; | 869 m_timing.direction = Timing::PlaybackDirectionAlternateReverse; |
966 // -- | |
967 | 870 |
968 // Curve is created | 871 OwnPtr<CompositorAnimation> animation = convertToCompositorAnimation(*effect ); |
969 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; | 872 EXPECT_EQ(CompositorTargetProperty::OPACITY, animation->targetProperty()); |
970 ExpectationSet usesMockCurve; | 873 EXPECT_EQ(5.0, animation->iterations()); |
971 EXPECT_CALL(*m_mockCompositorFactory, createFloatAnimationCurve()) | 874 EXPECT_EQ(-negativeStartDelay, animation->timeOffset()); |
972 .WillOnce(Return(mockCurvePtr)); | 875 EXPECT_EQ(CompositorAnimation::Direction::ALTERNATE_REVERSE, animation->getD irection()); |
876 EXPECT_EQ(1.0, animation->playbackRate()); | |
973 | 877 |
974 usesMockCurve += EXPECT_CALL(*mockCurvePtr, addLinearKeyframe(CompositorFloa tKeyframe(0.0, 2.0))); | 878 OwnPtr<CompositorFloatAnimationCurve> keyframedFloatCurve = animation->float CurveForTesting(); |
975 usesMockCurve += EXPECT_CALL(*mockCurvePtr, addCubicBezierKeyframe(Composito rFloatKeyframe(1.5, 5.0), CubicBezierTimingFunction::EaseType::EASE)); | |
976 | 879 |
977 // Create animation | 880 Vector<CompositorFloatKeyframe> keyframes = keyframedFloatCurve->keyframesFo rTesting(); |
978 WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMoc k(CompositorTargetProperty::OPACITY); | 881 ASSERT_EQ(2UL, keyframes.size()); |
979 ExpectationSet usesMockAnimation; | |
980 | |
981 usesMockCurve += EXPECT_CALL(*m_mockCompositorFactory, createAnimation(Ref(* mockCurvePtr), CompositorTargetProperty::OPACITY, _, _)) | |
982 .WillOnce(Return(mockAnimationPtr)); | |
983 | |
984 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(5)); | |
985 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(3.0)); | |
986 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setDirection(CompositorA nimation::Direction::ALTERNATE_REVERSE)); | |
987 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setPlaybackRate(1)); | |
988 | |
989 EXPECT_CALL(*mockAnimationPtr, delete_()) | |
990 .Times(1) | |
991 .After(usesMockAnimation); | |
992 EXPECT_CALL(*mockCurvePtr, delete_()) | |
993 .Times(1) | |
994 .After(usesMockCurve); | |
995 | |
996 // Go! | |
997 Vector<OwnPtr<CompositorAnimation>> result; | |
998 getAnimationOnCompositor(m_timing, *effect, result); | |
999 EXPECT_EQ(1U, result.size()); | |
1000 result[0].reset(); | |
1001 } | 882 } |
1002 | 883 |
1003 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationPlaybackRa tes) | 884 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationPlaybackRa tes) |
1004 { | 885 { |
1005 // KeyframeEffect to convert | 886 // KeyframeEffect to convert |
1006 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel( | 887 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel( |
1007 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0 ).get(), 0), | 888 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0 ).get(), 0), |
1008 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0 ).get(), 1.0)); | 889 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0 ).get(), 1.0)); |
1009 | 890 |
1010 m_timing.playbackRate = 2; | 891 const double playbackRate = 2; |
1011 // -- | 892 const double playerPlaybackRate = -1.5; |
1012 | 893 |
1013 // Curve is created | 894 m_timing.playbackRate = playbackRate; |
1014 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; | |
1015 ExpectationSet usesMockCurve; | |
1016 EXPECT_CALL(*m_mockCompositorFactory, createFloatAnimationCurve()) | |
1017 .WillOnce(Return(mockCurvePtr)); | |
1018 | 895 |
1019 usesMockCurve += EXPECT_CALL(*mockCurvePtr, addLinearKeyframe(CompositorFloa tKeyframe(0.0, 2.0))); | 896 OwnPtr<CompositorAnimation> animation = convertToCompositorAnimation(*effect , playerPlaybackRate); |
1020 usesMockCurve += EXPECT_CALL(*mockCurvePtr, addCubicBezierKeyframe(Composito rFloatKeyframe(1.0, 5.0), CubicBezierTimingFunction::EaseType::EASE)); | 897 EXPECT_EQ(CompositorTargetProperty::OPACITY, animation->targetProperty()); |
898 EXPECT_EQ(1.0, animation->iterations()); | |
899 EXPECT_EQ(0, animation->timeOffset()); | |
900 EXPECT_EQ(CompositorAnimation::Direction::NORMAL, animation->getDirection()) ; | |
901 EXPECT_EQ(playbackRate * playerPlaybackRate, animation->playbackRate()); | |
1021 | 902 |
1022 // Create animation | 903 OwnPtr<CompositorFloatAnimationCurve> keyframedFloatCurve = animation->float CurveForTesting(); |
1023 WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMoc k(CompositorTargetProperty::OPACITY); | |
1024 ExpectationSet usesMockAnimation; | |
1025 | 904 |
1026 usesMockCurve += EXPECT_CALL(*m_mockCompositorFactory, createAnimation(Ref(* mockCurvePtr), CompositorTargetProperty::OPACITY, _, _)) | 905 Vector<CompositorFloatKeyframe> keyframes = keyframedFloatCurve->keyframesFo rTesting(); |
1027 .WillOnce(Return(mockAnimationPtr)); | 906 ASSERT_EQ(2UL, keyframes.size()); |
1028 | |
1029 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(1)); | |
1030 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(0.0)); | |
1031 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setDirection(CompositorA nimation::Direction::NORMAL)); | |
1032 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setPlaybackRate(-3)); | |
1033 | |
1034 EXPECT_CALL(*mockAnimationPtr, delete_()) | |
1035 .Times(1) | |
1036 .After(usesMockAnimation); | |
1037 EXPECT_CALL(*mockCurvePtr, delete_()) | |
1038 .Times(1) | |
1039 .After(usesMockCurve); | |
1040 | |
1041 // Go! | |
1042 Vector<OwnPtr<CompositorAnimation>> result; | |
1043 // Set player plaback rate also | |
1044 getAnimationOnCompositor(m_timing, *effect, result, -1.5); | |
1045 EXPECT_EQ(1U, result.size()); | |
1046 result[0].reset(); | |
1047 } | 907 } |
1048 | 908 |
1049 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationFillModeNo ne) | 909 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationFillModeNo ne) |
1050 { | 910 { |
1051 // KeyframeEffect to convert | 911 // KeyframeEffect to convert |
1052 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel( | 912 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel( |
1053 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0 ).get(), 0), | 913 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0 ).get(), 0), |
1054 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0 ).get(), 1.0)); | 914 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0 ).get(), 1.0)); |
1055 | 915 |
1056 m_timing.fillMode = Timing::FillModeNone; | 916 m_timing.fillMode = Timing::FillModeNone; |
1057 | 917 |
1058 // Curve is created | 918 OwnPtr<CompositorAnimation> animation = convertToCompositorAnimation(*effect ); |
1059 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; | 919 EXPECT_EQ(CompositorAnimation::FillMode::NONE, animation->getFillMode()); |
1060 ExpectationSet usesMockCurve; | |
1061 EXPECT_CALL(*m_mockCompositorFactory, createFloatAnimationCurve()) | |
1062 .WillOnce(Return(mockCurvePtr)); | |
1063 | |
1064 usesMockCurve += EXPECT_CALL(*mockCurvePtr, addLinearKeyframe(CompositorFloa tKeyframe(0.0, 2.0))); | |
1065 usesMockCurve += EXPECT_CALL(*mockCurvePtr, addCubicBezierKeyframe(Composito rFloatKeyframe(1.0, 5.0), CubicBezierTimingFunction::EaseType::EASE)); | |
1066 | |
1067 // Create animation | |
1068 WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMoc k(CompositorTargetProperty::OPACITY); | |
1069 ExpectationSet usesMockAnimation; | |
1070 | |
1071 usesMockCurve += EXPECT_CALL(*m_mockCompositorFactory, createAnimation(Ref(* mockCurvePtr), CompositorTargetProperty::OPACITY, _, _)) | |
1072 .WillOnce(Return(mockAnimationPtr)); | |
1073 | |
1074 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(1)); | |
1075 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(0.0)); | |
1076 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setDirection(CompositorA nimation::Direction::NORMAL)); | |
1077 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setPlaybackRate(1)); | |
1078 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setFillMode(CompositorAn imation::FillMode::NONE)); | |
1079 | |
1080 EXPECT_CALL(*mockAnimationPtr, delete_()) | |
1081 .Times(1) | |
1082 .After(usesMockAnimation); | |
1083 EXPECT_CALL(*mockCurvePtr, delete_()) | |
1084 .Times(1) | |
1085 .After(usesMockCurve); | |
1086 | |
1087 // Go! | |
1088 Vector<OwnPtr<CompositorAnimation>> result; | |
1089 getAnimationOnCompositor(m_timing, *effect, result); | |
1090 EXPECT_EQ(1U, result.size()); | |
1091 result[0].reset(); | |
1092 } | 920 } |
1093 | 921 |
1094 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationFillModeAu to) | 922 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationFillModeAu to) |
1095 { | 923 { |
1096 // KeyframeEffect to convert | 924 // KeyframeEffect to convert |
1097 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel( | 925 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel( |
1098 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0 ).get(), 0), | 926 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0 ).get(), 0), |
1099 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0 ).get(), 1.0)); | 927 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0 ).get(), 1.0)); |
1100 | 928 |
1101 m_timing.fillMode = Timing::FillModeAuto; | 929 m_timing.fillMode = Timing::FillModeAuto; |
1102 | 930 |
1103 // Curve is created | 931 OwnPtr<CompositorAnimation> animation = convertToCompositorAnimation(*effect ); |
1104 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; | 932 EXPECT_EQ(CompositorTargetProperty::OPACITY, animation->targetProperty()); |
1105 ExpectationSet usesMockCurve; | 933 EXPECT_EQ(1.0, animation->iterations()); |
1106 EXPECT_CALL(*m_mockCompositorFactory, createFloatAnimationCurve()) | 934 EXPECT_EQ(0, animation->timeOffset()); |
1107 .WillOnce(Return(mockCurvePtr)); | 935 EXPECT_EQ(CompositorAnimation::Direction::NORMAL, animation->getDirection()) ; |
1108 | 936 EXPECT_EQ(1.0, animation->playbackRate()); |
1109 usesMockCurve += EXPECT_CALL(*mockCurvePtr, addLinearKeyframe(CompositorFloa tKeyframe(0.0, 2.0))); | 937 EXPECT_EQ(CompositorAnimation::FillMode::NONE, animation->getFillMode()); |
alancutter (OOO until 2018)
2016/06/01 02:20:55
It would be okay to just test the fill mode here b
loyso (OOO)
2016/06/01 02:36:47
Acknowledged.
| |
1110 usesMockCurve += EXPECT_CALL(*mockCurvePtr, addCubicBezierKeyframe(Composito rFloatKeyframe(1.0, 5.0), CubicBezierTimingFunction::EaseType::EASE)); | |
1111 | |
1112 // Create animation | |
1113 WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMoc k(CompositorTargetProperty::OPACITY); | |
1114 ExpectationSet usesMockAnimation; | |
1115 | |
1116 usesMockCurve += EXPECT_CALL(*m_mockCompositorFactory, createAnimation(Ref(* mockCurvePtr), CompositorTargetProperty::OPACITY, _, _)) | |
1117 .WillOnce(Return(mockAnimationPtr)); | |
1118 | |
1119 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(1)); | |
1120 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(0.0)); | |
1121 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setDirection(CompositorA nimation::Direction::NORMAL)); | |
1122 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setPlaybackRate(1)); | |
1123 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setFillMode(CompositorAn imation::FillMode::NONE)); | |
1124 | |
1125 EXPECT_CALL(*mockAnimationPtr, delete_()) | |
1126 .Times(1) | |
1127 .After(usesMockAnimation); | |
1128 EXPECT_CALL(*mockCurvePtr, delete_()) | |
1129 .Times(1) | |
1130 .After(usesMockCurve); | |
1131 | |
1132 // Go! | |
1133 Vector<OwnPtr<CompositorAnimation>> result; | |
1134 getAnimationOnCompositor(m_timing, *effect, result); | |
1135 EXPECT_EQ(1U, result.size()); | |
1136 result[0].reset(); | |
1137 } | 938 } |
1138 | 939 |
1139 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationWithTiming Function) | 940 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationWithTiming Function) |
1140 { | 941 { |
1141 // KeyframeEffect to convert | 942 // KeyframeEffect to convert |
1142 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel( | 943 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel( |
1143 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0 ).get(), 0), | 944 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0 ).get(), 0), |
1144 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0 ).get(), 1.0)); | 945 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0 ).get(), 1.0)); |
1145 | 946 |
1146 m_timing.timingFunction = m_cubicCustomTimingFunction; | 947 m_timing.timingFunction = m_cubicCustomTimingFunction; |
1147 | 948 |
1148 // Curve is created | 949 OwnPtr<CompositorAnimation> animation = convertToCompositorAnimation(*effect ); |
1149 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; | |
1150 ExpectationSet usesMockCurve; | |
1151 EXPECT_CALL(*m_mockCompositorFactory, createFloatAnimationCurve()) | |
1152 .WillOnce(Return(mockCurvePtr)); | |
1153 | 950 |
1154 usesMockCurve += EXPECT_CALL(*mockCurvePtr, addLinearKeyframe(CompositorFloa tKeyframe(0.0, 2.0))); | 951 OwnPtr<CompositorFloatAnimationCurve> keyframedFloatCurve = animation->float CurveForTesting(); |
1155 usesMockCurve += EXPECT_CALL(*mockCurvePtr, addCubicBezierKeyframe(Composito rFloatKeyframe(1.0, 5.0), CubicBezierTimingFunction::EaseType::EASE)); | |
1156 usesMockCurve += EXPECT_CALL(*mockCurvePtr, setCubicBezierTimingFunction(1, 2, 3, 4)); | |
1157 | 952 |
1158 // Create animation | 953 Vector<CompositorFloatKeyframe> keyframes = keyframedFloatCurve->keyframesFo rTesting(); |
1159 WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMoc k(CompositorTargetProperty::OPACITY); | 954 ASSERT_EQ(2UL, keyframes.size()); |
1160 ExpectationSet usesMockAnimation; | |
1161 | 955 |
1162 usesMockCurve += EXPECT_CALL(*m_mockCompositorFactory, createAnimation(Ref(* mockCurvePtr), CompositorTargetProperty::OPACITY, _, _)) | 956 EXPECT_EQ(CubicBezierTimingFunction::EaseType::CUSTOM, keyframedFloatCurve-> getCurveEaseTypeForTesting()); |
1163 .WillOnce(Return(mockAnimationPtr)); | |
1164 | 957 |
1165 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(1)); | 958 EXPECT_EQ(0, keyframes[0].time); |
1166 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(0.0)); | 959 EXPECT_EQ(2.0f, keyframes[0].value); |
1167 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setDirection(CompositorA nimation::Direction::NORMAL)); | 960 EXPECT_TRUE(keyframedFloatCurve->keyframeHasLinearTimingFunctionForTesting(0 )); |
1168 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setPlaybackRate(1)); | |
1169 | 961 |
1170 EXPECT_CALL(*mockAnimationPtr, delete_()) | 962 EXPECT_EQ(1.0, keyframes[1].time); |
1171 .Times(1) | 963 EXPECT_EQ(5.0f, keyframes[1].value); |
1172 .After(usesMockAnimation); | 964 EXPECT_EQ(CubicBezierTimingFunction::EaseType::EASE, keyframedFloatCurve->ge tKeyframeEaseTypeForTesting(1)); |
1173 EXPECT_CALL(*mockCurvePtr, delete_()) | |
1174 .Times(1) | |
1175 .After(usesMockCurve); | |
1176 | |
1177 // Go! | |
1178 Vector<OwnPtr<CompositorAnimation>> result; | |
1179 getAnimationOnCompositor(m_timing, *effect, result); | |
1180 EXPECT_EQ(1U, result.size()); | |
1181 result[0].reset(); | |
1182 } | 965 } |
1183 | 966 |
1184 TEST_F(AnimationCompositorAnimationsTest, CancelIncompatibleCompositorAnimations ) | 967 TEST_F(AnimationCompositorAnimationsTest, cancelIncompatibleCompositorAnimations ) |
1185 { | 968 { |
1186 Persistent<Element> element = m_document->createElement("shared", ASSERT_NO_ EXCEPTION); | 969 Persistent<Element> element = m_document->createElement("shared", ASSERT_NO_ EXCEPTION); |
1187 | 970 |
1188 LayoutObjectProxy* layoutObject = LayoutObjectProxy::create(element.get()); | 971 LayoutObjectProxy* layoutObject = LayoutObjectProxy::create(element.get()); |
1189 element->setLayoutObject(layoutObject); | 972 element->setLayoutObject(layoutObject); |
1190 | 973 |
1191 AnimatableValueKeyframeVector keyFrames; | 974 AnimatableValueKeyframeVector keyFrames; |
1192 keyFrames.append(createDefaultKeyframe(CSSPropertyOpacity, EffectModel::Comp ositeReplace, 0.0).get()); | 975 keyFrames.append(createDefaultKeyframe(CSSPropertyOpacity, EffectModel::Comp ositeReplace, 0.0).get()); |
1193 keyFrames.append(createDefaultKeyframe(CSSPropertyOpacity, EffectModel::Comp ositeReplace, 1.0).get()); | 976 keyFrames.append(createDefaultKeyframe(CSSPropertyOpacity, EffectModel::Comp ositeReplace, 1.0).get()); |
1194 EffectModel* animationEffect1 = AnimatableValueKeyframeEffectModel::create(k eyFrames); | 977 EffectModel* animationEffect1 = AnimatableValueKeyframeEffectModel::create(k eyFrames); |
(...skipping 30 matching lines...) Expand all Loading... | |
1225 simulateFrame(1.); | 1008 simulateFrame(1.); |
1226 | 1009 |
1227 element->setLayoutObject(nullptr); | 1010 element->setLayoutObject(nullptr); |
1228 LayoutObjectProxy::dispose(layoutObject); | 1011 LayoutObjectProxy::dispose(layoutObject); |
1229 | 1012 |
1230 ThreadHeap::collectAllGarbage(); | 1013 ThreadHeap::collectAllGarbage(); |
1231 EXPECT_TRUE(element->elementAnimations()->animations().isEmpty()); | 1014 EXPECT_TRUE(element->elementAnimations()->animations().isEmpty()); |
1232 } | 1015 } |
1233 | 1016 |
1234 } // namespace blink | 1017 } // namespace blink |
OLD | NEW |