Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: third_party/WebKit/Source/core/animation/CompositorAnimationsTest.cpp

Issue 2019613002: Blink Compositor Animation: Make Animation and Curve methods non-virtual. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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/CompositorFloatKeyframe.h"
49 #include "platform/geometry/FloatBox.h" 49 #include "platform/geometry/FloatBox.h"
50 #include "platform/geometry/IntSize.h" 50 #include "platform/geometry/IntSize.h"
51 #include "platform/graphics/filters/FilterOperations.h" 51 #include "platform/graphics/filters/FilterOperations.h"
52 #include "platform/testing/CompositorAnimationsTestUtils.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 // CompositorFloatKeyframe is a plain struct, so we just create an == operator
jbroman 2016/05/27 14:52:55 Not introduced in this CL, but obligatory warning:
loyso (OOO) 2016/05/31 02:20:39 Acknowledged. These particular helpers were not us
65 using ::testing::Ref; 65 // for it.
66 using ::testing::Return; 66 bool operator==(const CompositorFloatKeyframe& a, const CompositorFloatKeyframe& b)
67 using ::testing::_; 67 {
68 return a.time == b.time && a.value == b.value;
69 }
68 70
69 class AnimationCompositorAnimationsTest : public AnimationCompositorAnimationsTe stBase { 71 void PrintTo(const CompositorFloatKeyframe& frame, ::std::ostream* os)
72 {
73 *os << "CompositorFloatKeyframe@" << &frame << "(" << frame.time << ", " << frame.value << ")";
74 }
75
76
77 class AnimationCompositorAnimationsTest : public ::testing::Test {
70 protected: 78 protected:
71 RefPtr<TimingFunction> m_linearTimingFunction; 79 RefPtr<TimingFunction> m_linearTimingFunction;
72 RefPtr<TimingFunction> m_cubicEaseTimingFunction; 80 RefPtr<TimingFunction> m_cubicEaseTimingFunction;
73 RefPtr<TimingFunction> m_cubicCustomTimingFunction; 81 RefPtr<TimingFunction> m_cubicCustomTimingFunction;
74 RefPtr<TimingFunction> m_stepTimingFunction; 82 RefPtr<TimingFunction> m_stepTimingFunction;
75 83
76 Timing m_timing; 84 Timing m_timing;
77 CompositorAnimationsImpl::CompositorTiming m_compositorTiming; 85 CompositorAnimationsImpl::CompositorTiming m_compositorTiming;
78 OwnPtr<AnimatableValueKeyframeVector> m_keyframeVector2; 86 OwnPtr<AnimatableValueKeyframeVector> m_keyframeVector2;
79 Persistent<AnimatableValueKeyframeEffectModel> m_keyframeAnimationEffect2; 87 Persistent<AnimatableValueKeyframeEffectModel> m_keyframeAnimationEffect2;
80 OwnPtr<AnimatableValueKeyframeVector> m_keyframeVector5; 88 OwnPtr<AnimatableValueKeyframeVector> m_keyframeVector5;
81 Persistent<AnimatableValueKeyframeEffectModel> m_keyframeAnimationEffect5; 89 Persistent<AnimatableValueKeyframeEffectModel> m_keyframeAnimationEffect5;
82 90
83 Persistent<Document> m_document; 91 Persistent<Document> m_document;
84 Persistent<Element> m_element; 92 Persistent<Element> m_element;
85 Persistent<AnimationTimeline> m_timeline; 93 Persistent<AnimationTimeline> m_timeline;
86 OwnPtr<DummyPageHolder> m_pageHolder; 94 OwnPtr<DummyPageHolder> m_pageHolder;
87 CompositorFactoryMock* m_mockCompositorFactory;
88 95
89 void SetUp() override 96 void SetUp() override
90 { 97 {
91 AnimationCompositorAnimationsTestBase::SetUp();
92
93 m_mockCompositorFactory = new CompositorFactoryMock();
94 CompositorFactory::initializeForTesting(adoptPtr(m_mockCompositorFactory ));
95
96 m_linearTimingFunction = LinearTimingFunction::shared(); 98 m_linearTimingFunction = LinearTimingFunction::shared();
97 m_cubicEaseTimingFunction = CubicBezierTimingFunction::preset(CubicBezie rTimingFunction::EaseType::EASE); 99 m_cubicEaseTimingFunction = CubicBezierTimingFunction::preset(CubicBezie rTimingFunction::EaseType::EASE);
98 m_cubicCustomTimingFunction = CubicBezierTimingFunction::create(1, 2, 3, 4); 100 m_cubicCustomTimingFunction = CubicBezierTimingFunction::create(1, 2, 3, 4);
99 m_stepTimingFunction = StepsTimingFunction::create(1, StepsTimingFunctio n::StepPosition::END); 101 m_stepTimingFunction = StepsTimingFunction::create(1, StepsTimingFunctio n::StepPosition::END);
100 102
101 m_timing = createCompositableTiming(); 103 m_timing = createCompositableTiming();
102 m_compositorTiming = CompositorAnimationsImpl::CompositorTiming(); 104 m_compositorTiming = CompositorAnimationsImpl::CompositorTiming();
103 // Make sure the CompositableTiming is really compositable, otherwise 105 // Make sure the CompositableTiming is really compositable, otherwise
104 // most other tests will fail. 106 // most other tests will fail.
105 ASSERT(convertTimingForCompositor(m_timing, m_compositorTiming)); 107 ASSERT(convertTimingForCompositor(m_timing, m_compositorTiming));
106 108
107 m_keyframeVector2 = createCompositableFloatKeyframeVector(2); 109 m_keyframeVector2 = createCompositableFloatKeyframeVector(2);
108 m_keyframeAnimationEffect2 = AnimatableValueKeyframeEffectModel::create( *m_keyframeVector2); 110 m_keyframeAnimationEffect2 = AnimatableValueKeyframeEffectModel::create( *m_keyframeVector2);
109 111
110 m_keyframeVector5 = createCompositableFloatKeyframeVector(5); 112 m_keyframeVector5 = createCompositableFloatKeyframeVector(5);
111 m_keyframeAnimationEffect5 = AnimatableValueKeyframeEffectModel::create( *m_keyframeVector5); 113 m_keyframeAnimationEffect5 = AnimatableValueKeyframeEffectModel::create( *m_keyframeVector5);
112 114
113 EXPECT_CALL(*m_mockCompositorFactory, createAnimationTimeline())
114 .WillOnce(Return(new WebCompositorAnimationTimelineMock()));
115
116 m_pageHolder = DummyPageHolder::create(); 115 m_pageHolder = DummyPageHolder::create();
117 m_document = &m_pageHolder->document(); 116 m_document = &m_pageHolder->document();
118 m_document->animationClock().resetTimeForTesting(); 117 m_document->animationClock().resetTimeForTesting();
119 118
120 EXPECT_CALL(*m_mockCompositorFactory, createAnimationTimeline())
121 .WillOnce(Return(new WebCompositorAnimationTimelineMock()));
122
123 m_timeline = AnimationTimeline::create(m_document.get()); 119 m_timeline = AnimationTimeline::create(m_document.get());
124 m_timeline->resetForTesting(); 120 m_timeline->resetForTesting();
125 m_element = m_document->createElement("test", ASSERT_NO_EXCEPTION); 121 m_element = m_document->createElement("test", ASSERT_NO_EXCEPTION);
126 } 122 }
127 123
128 void TearDown() override
129 {
130 m_mockCompositorFactory = nullptr;
131 CompositorFactory::shutdown();
132 }
133
134 public: 124 public:
135 bool convertTimingForCompositor(const Timing& t, CompositorAnimationsImpl::C ompositorTiming& out) 125 bool convertTimingForCompositor(const Timing& t, CompositorAnimationsImpl::C ompositorTiming& out)
136 { 126 {
137 return CompositorAnimationsImpl::convertTimingForCompositor(t, 0, out, 1 ); 127 return CompositorAnimationsImpl::convertTimingForCompositor(t, 0, out, 1 );
138 } 128 }
139 bool isCandidateForAnimationOnCompositor(const Timing& timing, const EffectM odel& effect) 129 bool isCandidateForAnimationOnCompositor(const Timing& timing, const EffectM odel& effect)
140 { 130 {
141 return CompositorAnimations::instance()->isCandidateForAnimationOnCompos itor(timing, *m_element.get(), nullptr, effect, 1); 131 return CompositorAnimations::instance()->isCandidateForAnimationOnCompos itor(timing, *m_element.get(), nullptr, effect, 1);
142 } 132 }
143 void getAnimationOnCompositor(Timing& timing, AnimatableValueKeyframeEffectM odel& effect, Vector<OwnPtr<CompositorAnimation>>& animations) 133 void getAnimationOnCompositor(Timing& timing, AnimatableValueKeyframeEffectM odel& effect, Vector<OwnPtr<CompositorAnimation>>& animations)
144 { 134 {
145 return getAnimationOnCompositor(timing, effect, animations, 1); 135 getAnimationOnCompositor(timing, effect, animations, 1);
146 } 136 }
147 void getAnimationOnCompositor(Timing& timing, AnimatableValueKeyframeEffectM odel& effect, Vector<OwnPtr<CompositorAnimation>>& animations, double playerPlay backRate) 137 void getAnimationOnCompositor(Timing& timing, AnimatableValueKeyframeEffectM odel& effect, Vector<OwnPtr<CompositorAnimation>>& animations, double playerPlay backRate)
148 { 138 {
149 return CompositorAnimationsImpl::getAnimationOnCompositor(timing, 0, std ::numeric_limits<double>::quiet_NaN(), 0, effect, animations, playerPlaybackRate ); 139 CompositorAnimationsImpl::getAnimationOnCompositor(timing, 0, std::numer ic_limits<double>::quiet_NaN(), 0, effect, animations, playerPlaybackRate);
150 } 140 }
151 bool getAnimationBounds(FloatBox& boundingBox, const EffectModel& effect, do uble minValue, double maxValue) 141 bool getAnimationBounds(FloatBox& boundingBox, const EffectModel& effect, do uble minValue, double maxValue)
152 { 142 {
153 return CompositorAnimations::instance()->getAnimatedBoundingBox(bounding Box, effect, minValue, maxValue); 143 return CompositorAnimations::instance()->getAnimatedBoundingBox(bounding Box, effect, minValue, maxValue);
154 } 144 }
155 145
156 bool duplicateSingleKeyframeAndTestIsCandidateOnResult(AnimatableValueKeyfra me* frame) 146 bool duplicateSingleKeyframeAndTestIsCandidateOnResult(AnimatableValueKeyfra me* frame)
157 { 147 {
158 EXPECT_EQ(frame->offset(), 0); 148 EXPECT_EQ(frame->offset(), 0);
159 AnimatableValueKeyframeVector frames; 149 AnimatableValueKeyframeVector frames;
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 } 253 }
264 return nullptr; 254 return nullptr;
265 } 255 }
266 256
267 void simulateFrame(double time) 257 void simulateFrame(double time)
268 { 258 {
269 m_document->animationClock().updateTime(time); 259 m_document->animationClock().updateTime(time);
270 m_document->compositorPendingAnimations().update(false); 260 m_document->compositorPendingAnimations().update(false);
271 m_timeline->serviceAnimations(TimingUpdateForAnimationFrame); 261 m_timeline->serviceAnimations(TimingUpdateForAnimationFrame);
272 } 262 }
263
264 std::unique_ptr<CcAnimationForTesting> convertToCompositorAnimation(Animatab leValueKeyframeEffectModel& effect, double playerPlaybackRate)
265 {
266 Vector<OwnPtr<CompositorAnimation>> result;
267 getAnimationOnCompositor(m_timing, effect, result, playerPlaybackRate);
268 DCHECK_EQ(1U, result.size());
jbroman 2016/05/27 14:52:55 Here and elsewhere, you want ASSERT_EQ, not DCHECK
loyso (OOO) 2016/05/31 02:20:39 Partly done. It looks like it doesn't work in fun
jbroman 2016/06/01 14:51:28 Fair enough.
269 return result[0]->passAnimation();
270 }
271
272 std::unique_ptr<CcAnimationForTesting> convertToCompositorAnimation(Animatab leValueKeyframeEffectModel& effect)
273 {
274 return convertToCompositorAnimation(effect, 1.0);
275 }
276
277 const CcKeyframedFloatAnimationCurveForTesting* ToFloatCurve(const CcAnimati onForTesting* animation)
278 {
279 const CcAnimationCurveForTesting* curve = animation->curve();
280 DCHECK_EQ(CcAnimationCurveForTesting::FLOAT, curve->Type());
281 return static_cast<const CcKeyframedFloatAnimationCurveForTesting*>(curv e->ToFloatAnimationCurve());
282 }
283
284 const CcCubicBezierTimingFunctionForTesting* ToCubicBezier(const CcTimingFun ctionForTesting* timingFunction)
285 {
286 return static_cast<const CcCubicBezierTimingFunctionForTesting*>(timingF unction);
287 }
273 }; 288 };
274 289
275 class LayoutObjectProxy : public LayoutObject { 290 class LayoutObjectProxy : public LayoutObject {
276 public: 291 public:
277 static LayoutObjectProxy* create(Node* node) 292 static LayoutObjectProxy* create(Node* node)
278 { 293 {
279 return new LayoutObjectProxy(node); 294 return new LayoutObjectProxy(node);
280 } 295 }
281 296
282 static void dispose(LayoutObjectProxy* proxy) 297 static void dispose(LayoutObjectProxy* proxy)
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 664
650 // ----------------------------------------------------------------------- 665 // -----------------------------------------------------------------------
651 // ----------------------------------------------------------------------- 666 // -----------------------------------------------------------------------
652 667
653 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimation) 668 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimation)
654 { 669 {
655 // KeyframeEffect to convert 670 // KeyframeEffect to convert
656 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel( 671 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel(
657 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0 ).get(), 0), 672 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0 ).get(), 0),
658 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0 ).get(), 1.0)); 673 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0 ).get(), 1.0));
659 // --
660 674
661 // Curve is created 675 std::unique_ptr<CcAnimationForTesting> animation = convertToCompositorAnimat ion(*effect);
662 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; 676 EXPECT_EQ(CompositorTargetProperty::OPACITY, animation->target_property());
663 ExpectationSet usesMockCurve; 677 EXPECT_EQ(1.0, animation->iterations());
664 EXPECT_CALL(*m_mockCompositorFactory, createFloatAnimationCurve()) 678 EXPECT_EQ(TimeDeltaForTesting(), animation->time_offset());
665 .WillOnce(Return(mockCurvePtr)); 679 EXPECT_EQ(CompositorAnimation::Direction::NORMAL, animation->direction());
680 EXPECT_EQ(1.0, animation->playback_rate());
666 681
667 usesMockCurve += EXPECT_CALL(*mockCurvePtr, addLinearKeyframe(CompositorFloa tKeyframe(0.0, 2.0))); 682 const CcKeyframedFloatAnimationCurveForTesting* keyframedFloatCurve = ToFloa tCurve(animation.get());
668 usesMockCurve += EXPECT_CALL(*mockCurvePtr, addCubicBezierKeyframe(Composito rFloatKeyframe(1.0, 5.0), CubicBezierTimingFunction::EaseType::EASE));
669 683
670 // Create animation 684 DCHECK_EQ(2UL, keyframedFloatCurve->keyframes_for_testing().size());
671 WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMoc k(CompositorTargetProperty::OPACITY); 685 const CcFloatKeyframeForTesting* keyframe1 = keyframedFloatCurve->keyframes_ for_testing()[0].get();
672 ExpectationSet usesMockAnimation; 686 const CcFloatKeyframeForTesting* keyframe2 = keyframedFloatCurve->keyframes_ for_testing()[1].get();
687 EXPECT_EQ(TimeDeltaForTesting(), keyframe1->Time());
688 EXPECT_EQ(2.0f, keyframe1->Value());
673 689
674 usesMockCurve += EXPECT_CALL(*m_mockCompositorFactory, createAnimation(Ref(* mockCurvePtr), CompositorTargetProperty::OPACITY, _, _)) 690 EXPECT_EQ(TimeDeltaForTesting::FromSecondsD(1.0), keyframe2->Time());
675 .WillOnce(Return(mockAnimationPtr)); 691 EXPECT_EQ(5.0f, keyframe2->Value());
676 692 const CcCubicBezierTimingFunctionForTesting* cubic = ToCubicBezier(keyframe2 ->timing_function());
677 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(1)); 693 EXPECT_EQ(CubicBezierTimingFunction::EaseType::EASE, cubic->ease_type());
678 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(0.0));
679 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setDirection(CompositorA nimation::Direction::NORMAL));
680 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setPlaybackRate(1));
681
682 EXPECT_CALL(*mockAnimationPtr, delete_())
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 } 694 }
695 695
696 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationDuration) 696 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationDuration)
697 { 697 {
698 // KeyframeEffect to convert 698 // KeyframeEffect to convert
699 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel( 699 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel(
700 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0 ).get(), 0), 700 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0 ).get(), 0),
701 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0 ).get(), 1.0)); 701 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0 ).get(), 1.0));
702 702
703 m_timing.iterationDuration = 10.0; 703 const double duration = 10.0;
704 // -- 704 m_timing.iterationDuration = duration;
705 705
706 // Curve is created 706 std::unique_ptr<CcAnimationForTesting> animation = convertToCompositorAnimat ion(*effect);
707 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; 707 const CcKeyframedFloatAnimationCurveForTesting* keyframedFloatCurve = ToFloa tCurve(animation.get());
708 ExpectationSet usesMockCurve;
709 EXPECT_CALL(*m_mockCompositorFactory, createFloatAnimationCurve())
710 .WillOnce(Return(mockCurvePtr));
711 708
712 usesMockCurve += EXPECT_CALL(*mockCurvePtr, addLinearKeyframe(CompositorFloa tKeyframe(0.0, 2.0))); 709 DCHECK_EQ(2UL, keyframedFloatCurve->keyframes_for_testing().size());
713 usesMockCurve += EXPECT_CALL(*mockCurvePtr, addCubicBezierKeyframe(Composito rFloatKeyframe(10.0, 5.0), CubicBezierTimingFunction::EaseType::EASE)); 710 const CcFloatKeyframeForTesting* keyframe2 = keyframedFloatCurve->keyframes_ for_testing()[1].get();
714 711 EXPECT_EQ(TimeDeltaForTesting::FromSecondsD(duration), keyframe2->Time());
715 // Create animation
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 } 712 }
740 713
741 TEST_F(AnimationCompositorAnimationsTest, createMultipleKeyframeOpacityAnimation Linear) 714 TEST_F(AnimationCompositorAnimationsTest, createMultipleKeyframeOpacityAnimation Linear)
742 { 715 {
743 // KeyframeEffect to convert 716 // KeyframeEffect to convert
744 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel( 717 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel(
745 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0 ).get(), 0), 718 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0 ).get(), 0),
746 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(-1. 0).get(), 0.25), 719 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(-1. 0).get(), 0.25),
747 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(20. 0).get(), 0.5), 720 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(20. 0).get(), 0.5),
748 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0 ).get(), 1.0)); 721 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0 ).get(), 1.0));
749 722
750 m_timing.iterationCount = 5; 723 m_timing.iterationCount = 5;
751 m_timing.direction = Timing::PlaybackDirectionAlternate; 724 m_timing.direction = Timing::PlaybackDirectionAlternate;
752 m_timing.playbackRate = 2.0; 725 m_timing.playbackRate = 2.0;
753 // --
754 726
755 // Curve is created 727 std::unique_ptr<CcAnimationForTesting> animation = convertToCompositorAnimat ion(*effect);
756 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock(); 728 EXPECT_EQ(CompositorTargetProperty::OPACITY, animation->target_property());
757 ExpectationSet usesMockCurve; 729 EXPECT_EQ(5.0, animation->iterations());
730 EXPECT_EQ(TimeDeltaForTesting(), animation->time_offset());
731 EXPECT_EQ(CompositorAnimation::Direction::ALTERNATE_NORMAL, animation->direc tion());
732 EXPECT_EQ(2.0, animation->playback_rate());
758 733
759 EXPECT_CALL(*m_mockCompositorFactory, createFloatAnimationCurve()) 734 const CcKeyframedFloatAnimationCurveForTesting* keyframedFloatCurve = ToFloa tCurve(animation.get());
760 .WillOnce(Return(mockCurvePtr)); 735 DCHECK_EQ(4UL, keyframedFloatCurve->keyframes_for_testing().size());
761 736
762 usesMockCurve += EXPECT_CALL(*mockCurvePtr, addLinearKeyframe(CompositorFloa tKeyframe(0.0, 2.0))); 737 const CcFloatKeyframeForTesting* keyframe1 = keyframedFloatCurve->keyframes_ for_testing()[0].get();
763 usesMockCurve += EXPECT_CALL(*mockCurvePtr, addLinearKeyframe(CompositorFloa tKeyframe(0.25, -1.0))); 738 EXPECT_EQ(TimeDeltaForTesting(), keyframe1->Time());
764 usesMockCurve += EXPECT_CALL(*mockCurvePtr, addLinearKeyframe(CompositorFloa tKeyframe(0.5, 20.0))); 739 EXPECT_EQ(2.0f, keyframe1->Value());
765 usesMockCurve += EXPECT_CALL(*mockCurvePtr, addCubicBezierKeyframe(Composito rFloatKeyframe(1.0, 5.0), CubicBezierTimingFunction::EaseType::EASE)); 740 EXPECT_FALSE(keyframe1->timing_function());
766 741
767 // KeyframeEffect is created 742 const CcFloatKeyframeForTesting* keyframe2 = keyframedFloatCurve->keyframes_ for_testing()[1].get();
768 WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMoc k(CompositorTargetProperty::OPACITY); 743 EXPECT_EQ(TimeDeltaForTesting::FromSecondsD(0.25), keyframe2->Time());
769 ExpectationSet usesMockAnimation; 744 EXPECT_EQ(-1.0f, keyframe2->Value());
745 EXPECT_FALSE(keyframe2->timing_function());
770 746
771 usesMockCurve += EXPECT_CALL(*m_mockCompositorFactory, createAnimation(Ref(* mockCurvePtr), CompositorTargetProperty::OPACITY, _, _)) 747 const CcFloatKeyframeForTesting* keyframe3 = keyframedFloatCurve->keyframes_ for_testing()[2].get();
772 .WillOnce(Return(mockAnimationPtr)); 748 EXPECT_EQ(TimeDeltaForTesting::FromSecondsD(0.5), keyframe3->Time());
749 EXPECT_EQ(20.0f, keyframe3->Value());
750 EXPECT_FALSE(keyframe3->timing_function());
773 751
774 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(5)); 752 const CcFloatKeyframeForTesting* keyframe4 = keyframedFloatCurve->keyframes_ for_testing()[3].get();
775 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(0.0)); 753 EXPECT_EQ(TimeDeltaForTesting::FromSecondsD(1.0), keyframe4->Time());
776 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setDirection(CompositorA nimation::Direction::ALTERNATE_NORMAL)); 754 EXPECT_EQ(5.0f, keyframe4->Value());
777 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setPlaybackRate(2.0)); 755 const CcCubicBezierTimingFunctionForTesting* cubic = ToCubicBezier(keyframe4 ->timing_function());
778 756 EXPECT_EQ(CubicBezierTimingFunction::EaseType::EASE, cubic->ease_type());
779 EXPECT_CALL(*mockAnimationPtr, delete_())
780 .Times(1)
781 .After(usesMockAnimation);
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 } 757 }
792 758
793 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationStartDelay ) 759 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationStartDelay )
794 { 760 {
795 // KeyframeEffect to convert 761 // KeyframeEffect to convert
796 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel( 762 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel(
797 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0 ).get(), 0), 763 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0 ).get(), 0),
798 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0 ).get(), 1.0)); 764 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0 ).get(), 1.0));
799 765
766 const double startDelay = 3.25;
767
800 m_timing.iterationCount = 5.0; 768 m_timing.iterationCount = 5.0;
801 m_timing.iterationDuration = 1.75; 769 m_timing.iterationDuration = 1.75;
802 m_timing.startDelay = 3.25; 770 m_timing.startDelay = startDelay;
803 // --
804 771
805 // Curve is created 772 std::unique_ptr<CcAnimationForTesting> animation = convertToCompositorAnimat ion(*effect);
806 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock;
807 ExpectationSet usesMockCurve;
808 EXPECT_CALL(*m_mockCompositorFactory, createFloatAnimationCurve())
809 .WillOnce(Return(mockCurvePtr));
810 773
811 usesMockCurve += EXPECT_CALL(*mockCurvePtr, addLinearKeyframe(CompositorFloa tKeyframe(0.0, 2.0))); 774 EXPECT_EQ(CompositorTargetProperty::OPACITY, animation->target_property());
812 usesMockCurve += EXPECT_CALL(*mockCurvePtr, addCubicBezierKeyframe(Composito rFloatKeyframe(1.75, 5.0), CubicBezierTimingFunction::EaseType::EASE)); 775 EXPECT_EQ(5.0, animation->iterations());
776 EXPECT_EQ(TimeDeltaForTesting::FromSecondsD(-startDelay), animation->time_of fset());
813 777
814 // Create animation 778 const CcKeyframedFloatAnimationCurveForTesting* keyframedFloatCurve = ToFloa tCurve(animation.get());
815 WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMoc k(CompositorTargetProperty::OPACITY); 779 DCHECK_EQ(2UL, keyframedFloatCurve->keyframes_for_testing().size());
816 ExpectationSet usesMockAnimation;
817 780
818 usesMockCurve += EXPECT_CALL(*m_mockCompositorFactory, createAnimation(Ref(* mockCurvePtr), CompositorTargetProperty::OPACITY, _, _)) 781 const CcFloatKeyframeForTesting* keyframe2 = keyframedFloatCurve->keyframes_ for_testing()[1].get();
819 .WillOnce(Return(mockAnimationPtr)); 782 EXPECT_EQ(TimeDeltaForTesting::FromSecondsD(1.75), keyframe2->Time());
820 783 EXPECT_EQ(5.0f, keyframe2->Value());
821 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(5));
822 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(-3.25));
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 } 784 }
839 785
840 TEST_F(AnimationCompositorAnimationsTest, createMultipleKeyframeOpacityAnimation Chained) 786 TEST_F(AnimationCompositorAnimationsTest, createMultipleKeyframeOpacityAnimation Chained)
841 { 787 {
842 // KeyframeEffect to convert 788 // KeyframeEffect to convert
843 AnimatableValueKeyframeVector frames; 789 AnimatableValueKeyframeVector frames;
844 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble:: create(2.0).get(), 0)); 790 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble:: create(2.0).get(), 0));
845 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble:: create(-1.0).get(), 0.25)); 791 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble:: create(-1.0).get(), 0.25));
846 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble:: create(20.0).get(), 0.5)); 792 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble:: create(20.0).get(), 0.5));
847 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble:: create(5.0).get(), 1.0)); 793 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble:: create(5.0).get(), 1.0));
848 frames[0]->setEasing(m_cubicEaseTimingFunction.get()); 794 frames[0]->setEasing(m_cubicEaseTimingFunction.get());
849 frames[1]->setEasing(m_linearTimingFunction.get()); 795 frames[1]->setEasing(m_linearTimingFunction.get());
850 frames[2]->setEasing(m_cubicCustomTimingFunction.get()); 796 frames[2]->setEasing(m_cubicCustomTimingFunction.get());
851 AnimatableValueKeyframeEffectModel* effect = AnimatableValueKeyframeEffectMo del::create(frames); 797 AnimatableValueKeyframeEffectModel* effect = AnimatableValueKeyframeEffectMo del::create(frames);
852 798
853 m_timing.timingFunction = m_linearTimingFunction.get(); 799 m_timing.timingFunction = m_linearTimingFunction.get();
854 m_timing.iterationDuration = 2.0; 800 m_timing.iterationDuration = 2.0;
855 m_timing.iterationCount = 10; 801 m_timing.iterationCount = 10;
856 m_timing.direction = Timing::PlaybackDirectionAlternate; 802 m_timing.direction = Timing::PlaybackDirectionAlternate;
857 // --
858 803
859 // Curve is created 804 std::unique_ptr<CcAnimationForTesting> animation = convertToCompositorAnimat ion(*effect);
860 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock(); 805 EXPECT_EQ(CompositorTargetProperty::OPACITY, animation->target_property());
861 ExpectationSet usesMockCurve; 806 EXPECT_EQ(10.0, animation->iterations());
807 EXPECT_EQ(TimeDeltaForTesting(), animation->time_offset());
808 EXPECT_EQ(CompositorAnimation::Direction::ALTERNATE_NORMAL, animation->direc tion());
809 EXPECT_EQ(1.0, animation->playback_rate());
862 810
863 EXPECT_CALL(*m_mockCompositorFactory, createFloatAnimationCurve()) 811 const CcKeyframedFloatAnimationCurveForTesting* keyframedFloatCurve = ToFloa tCurve(animation.get());
864 .WillOnce(Return(mockCurvePtr)); 812 DCHECK_EQ(4UL, keyframedFloatCurve->keyframes_for_testing().size());
865 813
866 usesMockCurve += EXPECT_CALL(*mockCurvePtr, addCubicBezierKeyframe(Composito rFloatKeyframe(0.0, 2.0), CubicBezierTimingFunction::EaseType::EASE)); 814 const CcFloatKeyframeForTesting* keyframe1 = keyframedFloatCurve->keyframes_ for_testing()[0].get();
867 usesMockCurve += EXPECT_CALL(*mockCurvePtr, addLinearKeyframe(CompositorFloa tKeyframe(0.5, -1.0))); 815 EXPECT_EQ(TimeDeltaForTesting(), keyframe1->Time());
868 usesMockCurve += EXPECT_CALL(*mockCurvePtr, addCubicBezierKeyframe(Composito rFloatKeyframe(1.0, 20.0), 1.0, 2.0, 3.0, 4.0)); 816 EXPECT_EQ(2.0f, keyframe1->Value());
869 usesMockCurve += EXPECT_CALL(*mockCurvePtr, addCubicBezierKeyframe(Composito rFloatKeyframe(2.0, 5.0), CubicBezierTimingFunction::EaseType::EASE)); 817 const CcCubicBezierTimingFunctionForTesting* cubic1 = ToCubicBezier(keyframe 1->timing_function());
818 EXPECT_EQ(CubicBezierTimingFunction::EaseType::EASE, cubic1->ease_type());
870 819
871 // KeyframeEffect is created 820 const CcFloatKeyframeForTesting* keyframe2 = keyframedFloatCurve->keyframes_ for_testing()[1].get();
872 WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMoc k(CompositorTargetProperty::OPACITY); 821 EXPECT_EQ(TimeDeltaForTesting::FromSecondsD(0.5), keyframe2->Time());
873 ExpectationSet usesMockAnimation; 822 EXPECT_EQ(-1.0f, keyframe2->Value());
823 EXPECT_FALSE(keyframe2->timing_function());
874 824
875 usesMockCurve += EXPECT_CALL(*m_mockCompositorFactory, createAnimation(Ref(* mockCurvePtr), CompositorTargetProperty::OPACITY, _, _)) 825 const CcFloatKeyframeForTesting* keyframe3 = keyframedFloatCurve->keyframes_ for_testing()[2].get();
876 .WillOnce(Return(mockAnimationPtr)); 826 EXPECT_EQ(TimeDeltaForTesting::FromSecondsD(1.0), keyframe3->Time());
827 EXPECT_EQ(20.0f, keyframe3->Value());
828 const CcCubicBezierTimingFunctionForTesting* cubic3 = ToCubicBezier(keyframe 3->timing_function());
829 EXPECT_EQ(CubicBezierTimingFunction::EaseType::CUSTOM, cubic3->ease_type());
877 830
878 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(10)); 831 const CcFloatKeyframeForTesting* keyframe4 = keyframedFloatCurve->keyframes_ for_testing()[3].get();
879 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(0.0)); 832 EXPECT_EQ(TimeDeltaForTesting::FromSecondsD(2.0), keyframe4->Time());
880 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setDirection(CompositorA nimation::Direction::ALTERNATE_NORMAL)); 833 EXPECT_EQ(5.0f, keyframe4->Value());
881 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setPlaybackRate(1)); 834 const CcCubicBezierTimingFunctionForTesting* cubic4 = ToCubicBezier(keyframe 4->timing_function());
882 835 EXPECT_EQ(CubicBezierTimingFunction::EaseType::EASE, cubic4->ease_type());
883 EXPECT_CALL(*mockAnimationPtr, delete_())
884 .Times(1)
885 .After(usesMockAnimation);
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 } 836 }
896 837
897 TEST_F(AnimationCompositorAnimationsTest, createReversedOpacityAnimation) 838 TEST_F(AnimationCompositorAnimationsTest, createReversedOpacityAnimation)
898 { 839 {
899 RefPtr<TimingFunction> cubicEasyFlipTimingFunction = CubicBezierTimingFuncti on::create(0.0, 0.0, 0.0, 1.0); 840 RefPtr<TimingFunction> cubicEasyFlipTimingFunction = CubicBezierTimingFuncti on::create(0.0, 0.0, 0.0, 1.0);
900 841
901 // KeyframeEffect to convert 842 // KeyframeEffect to convert
902 AnimatableValueKeyframeVector frames; 843 AnimatableValueKeyframeVector frames;
903 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble:: create(2.0).get(), 0)); 844 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble:: create(2.0).get(), 0));
904 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble:: create(-1.0).get(), 0.25)); 845 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble:: create(-1.0).get(), 0.25));
905 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble:: create(20.0).get(), 0.5)); 846 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble:: create(20.0).get(), 0.5));
906 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble:: create(5.0).get(), 1.0)); 847 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble:: create(5.0).get(), 1.0));
907 frames[0]->setEasing(CubicBezierTimingFunction::preset(CubicBezierTimingFunc tion::EaseType::EASE_IN)); 848 frames[0]->setEasing(CubicBezierTimingFunction::preset(CubicBezierTimingFunc tion::EaseType::EASE_IN));
908 frames[1]->setEasing(m_linearTimingFunction.get()); 849 frames[1]->setEasing(m_linearTimingFunction.get());
909 frames[2]->setEasing(cubicEasyFlipTimingFunction.get()); 850 frames[2]->setEasing(cubicEasyFlipTimingFunction.get());
910 AnimatableValueKeyframeEffectModel* effect = AnimatableValueKeyframeEffectMo del::create(frames); 851 AnimatableValueKeyframeEffectModel* effect = AnimatableValueKeyframeEffectMo del::create(frames);
911 852
912 m_timing.timingFunction = m_linearTimingFunction.get(); 853 m_timing.timingFunction = m_linearTimingFunction.get();
913 m_timing.iterationCount = 10; 854 m_timing.iterationCount = 10;
914 m_timing.direction = Timing::PlaybackDirectionAlternateReverse; 855 m_timing.direction = Timing::PlaybackDirectionAlternateReverse;
915 // --
916 856
917 // Curve is created 857 std::unique_ptr<CcAnimationForTesting> animation = convertToCompositorAnimat ion(*effect);
918 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock(); 858 EXPECT_EQ(CompositorTargetProperty::OPACITY, animation->target_property());
919 ExpectationSet usesMockCurve; 859 EXPECT_EQ(10.0, animation->iterations());
860 EXPECT_EQ(TimeDeltaForTesting(), animation->time_offset());
861 EXPECT_EQ(CompositorAnimation::Direction::ALTERNATE_REVERSE, animation->dire ction());
862 EXPECT_EQ(1.0, animation->playback_rate());
920 863
921 EXPECT_CALL(*m_mockCompositorFactory, createFloatAnimationCurve()) 864 const CcKeyframedFloatAnimationCurveForTesting* keyframedFloatCurve = ToFloa tCurve(animation.get());
922 .WillOnce(Return(mockCurvePtr)); 865 DCHECK_EQ(4UL, keyframedFloatCurve->keyframes_for_testing().size());
866 EXPECT_FALSE(keyframedFloatCurve->timing_function_for_testing());
923 867
924 usesMockCurve += EXPECT_CALL(*mockCurvePtr, addCubicBezierKeyframe(Composito rFloatKeyframe(0.0, 2.0), CubicBezierTimingFunction::EaseType::EASE_IN)); 868 const CcFloatKeyframeForTesting* keyframe1 = keyframedFloatCurve->keyframes_ for_testing()[0].get();
925 usesMockCurve += EXPECT_CALL(*mockCurvePtr, addLinearKeyframe(CompositorFloa tKeyframe(0.25, -1.0))); 869 EXPECT_EQ(TimeDeltaForTesting(), keyframe1->Time());
926 usesMockCurve += EXPECT_CALL(*mockCurvePtr, addCubicBezierKeyframe(Composito rFloatKeyframe(0.5, 20.0), 0.0, 0.0, 0.0, 1.0)); 870 EXPECT_EQ(2.0f, keyframe1->Value());
927 usesMockCurve += EXPECT_CALL(*mockCurvePtr, addCubicBezierKeyframe(Composito rFloatKeyframe(1.0, 5.0), CubicBezierTimingFunction::EaseType::EASE)); 871 const CcCubicBezierTimingFunctionForTesting* cubic1 = ToCubicBezier(keyframe 1->timing_function());
872 EXPECT_EQ(CubicBezierTimingFunction::EaseType::EASE_IN, cubic1->ease_type()) ;
928 873
929 // Create the animation 874 const CcFloatKeyframeForTesting* keyframe2 = keyframedFloatCurve->keyframes_ for_testing()[1].get();
930 WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMoc k(CompositorTargetProperty::OPACITY); 875 EXPECT_EQ(TimeDeltaForTesting::FromSecondsD(0.25), keyframe2->Time());
931 ExpectationSet usesMockAnimation; 876 EXPECT_EQ(-1.0f, keyframe2->Value());
877 EXPECT_FALSE(keyframe2->timing_function());
932 878
933 usesMockCurve += EXPECT_CALL(*m_mockCompositorFactory, createAnimation(Ref(* mockCurvePtr), CompositorTargetProperty::OPACITY, _, _)) 879 const CcFloatKeyframeForTesting* keyframe3 = keyframedFloatCurve->keyframes_ for_testing()[2].get();
934 .WillOnce(Return(mockAnimationPtr)); 880 EXPECT_EQ(TimeDeltaForTesting::FromSecondsD(0.5), keyframe3->Time());
881 EXPECT_EQ(20.0f, keyframe3->Value());
882 const CcCubicBezierTimingFunctionForTesting* cubic3 = ToCubicBezier(keyframe 3->timing_function());
883 EXPECT_EQ(CubicBezierTimingFunction::EaseType::CUSTOM, cubic3->ease_type());
935 884
936 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(10)); 885 const CcFloatKeyframeForTesting* keyframe4 = keyframedFloatCurve->keyframes_ for_testing()[3].get();
937 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(0.0)); 886 EXPECT_EQ(TimeDeltaForTesting::FromSecondsD(1.0), keyframe4->Time());
938 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setDirection(CompositorA nimation::Direction::ALTERNATE_REVERSE)); 887 EXPECT_EQ(5.0f, keyframe4->Value());
939 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setPlaybackRate(1)); 888 const CcCubicBezierTimingFunctionForTesting* cubic4 = ToCubicBezier(keyframe 4->timing_function());
940 889 EXPECT_EQ(CubicBezierTimingFunction::EaseType::EASE, cubic4->ease_type());
941 EXPECT_CALL(*mockAnimationPtr, delete_())
942 .Times(1)
943 .After(usesMockAnimation);
944 EXPECT_CALL(*mockCurvePtr, delete_())
945 .Times(1)
946 .After(usesMockCurve);
947
948 // Go!
949 Vector<OwnPtr<CompositorAnimation>> result;
950 getAnimationOnCompositor(m_timing, *effect, result);
951 EXPECT_EQ(1U, result.size());
952 result[0].reset();
953 } 890 }
954 891
955 TEST_F(AnimationCompositorAnimationsTest, createReversedOpacityAnimationNegative StartDelay) 892 TEST_F(AnimationCompositorAnimationsTest, createReversedOpacityAnimationNegative StartDelay)
956 { 893 {
957 // KeyframeEffect to convert 894 // KeyframeEffect to convert
958 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel( 895 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel(
959 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0 ).get(), 0), 896 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0 ).get(), 0),
960 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0 ).get(), 1.0)); 897 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0 ).get(), 1.0));
961 898
899 const double negativeStartDelay = -3;
900
962 m_timing.iterationCount = 5.0; 901 m_timing.iterationCount = 5.0;
963 m_timing.iterationDuration = 1.5; 902 m_timing.iterationDuration = 1.5;
964 m_timing.startDelay = -3; 903 m_timing.startDelay = negativeStartDelay;
965 m_timing.direction = Timing::PlaybackDirectionAlternateReverse; 904 m_timing.direction = Timing::PlaybackDirectionAlternateReverse;
966 // --
967 905
968 // Curve is created 906 std::unique_ptr<CcAnimationForTesting> animation = convertToCompositorAnimat ion(*effect);
969 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; 907 EXPECT_EQ(CompositorTargetProperty::OPACITY, animation->target_property());
970 ExpectationSet usesMockCurve; 908 EXPECT_EQ(5.0, animation->iterations());
971 EXPECT_CALL(*m_mockCompositorFactory, createFloatAnimationCurve()) 909 EXPECT_EQ(TimeDeltaForTesting::FromSecondsD(-negativeStartDelay), animation- >time_offset());
972 .WillOnce(Return(mockCurvePtr)); 910 EXPECT_EQ(CompositorAnimation::Direction::ALTERNATE_REVERSE, animation->dire ction());
911 EXPECT_EQ(1.0, animation->playback_rate());
973 912
974 usesMockCurve += EXPECT_CALL(*mockCurvePtr, addLinearKeyframe(CompositorFloa tKeyframe(0.0, 2.0))); 913 const CcKeyframedFloatAnimationCurveForTesting* keyframedFloatCurve = ToFloa tCurve(animation.get());
975 usesMockCurve += EXPECT_CALL(*mockCurvePtr, addCubicBezierKeyframe(Composito rFloatKeyframe(1.5, 5.0), CubicBezierTimingFunction::EaseType::EASE)); 914 DCHECK_EQ(2UL, keyframedFloatCurve->keyframes_for_testing().size());
976
977 // Create animation
978 WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMoc k(CompositorTargetProperty::OPACITY);
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 } 915 }
1002 916
1003 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationPlaybackRa tes) 917 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationPlaybackRa tes)
1004 { 918 {
1005 // KeyframeEffect to convert 919 // KeyframeEffect to convert
1006 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel( 920 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel(
1007 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0 ).get(), 0), 921 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0 ).get(), 0),
1008 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0 ).get(), 1.0)); 922 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0 ).get(), 1.0));
1009 923
1010 m_timing.playbackRate = 2; 924 const double playbackRate = 2;
1011 // -- 925 const double playerPlaybackRate = -1.5;
1012 926
1013 // Curve is created 927 m_timing.playbackRate = playbackRate;
1014 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock;
1015 ExpectationSet usesMockCurve;
1016 EXPECT_CALL(*m_mockCompositorFactory, createFloatAnimationCurve())
1017 .WillOnce(Return(mockCurvePtr));
1018 928
1019 usesMockCurve += EXPECT_CALL(*mockCurvePtr, addLinearKeyframe(CompositorFloa tKeyframe(0.0, 2.0))); 929 std::unique_ptr<CcAnimationForTesting> animation = convertToCompositorAnimat ion(*effect, playerPlaybackRate);
1020 usesMockCurve += EXPECT_CALL(*mockCurvePtr, addCubicBezierKeyframe(Composito rFloatKeyframe(1.0, 5.0), CubicBezierTimingFunction::EaseType::EASE)); 930 EXPECT_EQ(CompositorTargetProperty::OPACITY, animation->target_property());
931 EXPECT_EQ(1.0, animation->iterations());
932 EXPECT_EQ(TimeDeltaForTesting(), animation->time_offset());
933 EXPECT_EQ(CompositorAnimation::Direction::NORMAL, animation->direction());
934 EXPECT_EQ(playbackRate * playerPlaybackRate, animation->playback_rate());
1021 935
1022 // Create animation 936 const CcKeyframedFloatAnimationCurveForTesting* keyframedFloatCurve = ToFloa tCurve(animation.get());
1023 WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMoc k(CompositorTargetProperty::OPACITY); 937 DCHECK_EQ(2UL, keyframedFloatCurve->keyframes_for_testing().size());
1024 ExpectationSet usesMockAnimation;
1025
1026 usesMockCurve += EXPECT_CALL(*m_mockCompositorFactory, createAnimation(Ref(* mockCurvePtr), CompositorTargetProperty::OPACITY, _, _))
1027 .WillOnce(Return(mockAnimationPtr));
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 } 938 }
1048 939
1049 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationFillModeNo ne) 940 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationFillModeNo ne)
1050 { 941 {
1051 // KeyframeEffect to convert 942 // KeyframeEffect to convert
1052 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel( 943 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel(
1053 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0 ).get(), 0), 944 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0 ).get(), 0),
1054 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0 ).get(), 1.0)); 945 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0 ).get(), 1.0));
1055 946
1056 m_timing.fillMode = Timing::FillModeNone; 947 m_timing.fillMode = Timing::FillModeNone;
1057 948
1058 // Curve is created 949 std::unique_ptr<CcAnimationForTesting> animation = convertToCompositorAnimat ion(*effect);
1059 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; 950 EXPECT_EQ(CompositorAnimation::FillMode::NONE, animation->fill_mode());
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 } 951 }
1093 952
1094 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationFillModeAu to) 953 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationFillModeAu to)
1095 { 954 {
1096 // KeyframeEffect to convert 955 // KeyframeEffect to convert
1097 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel( 956 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel(
1098 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0 ).get(), 0), 957 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0 ).get(), 0),
1099 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0 ).get(), 1.0)); 958 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0 ).get(), 1.0));
1100 959
1101 m_timing.fillMode = Timing::FillModeAuto; 960 m_timing.fillMode = Timing::FillModeAuto;
1102 961
1103 // Curve is created 962 std::unique_ptr<CcAnimationForTesting> animation = convertToCompositorAnimat ion(*effect);
1104 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; 963 EXPECT_EQ(CompositorTargetProperty::OPACITY, animation->target_property());
1105 ExpectationSet usesMockCurve; 964 EXPECT_EQ(1.0, animation->iterations());
1106 EXPECT_CALL(*m_mockCompositorFactory, createFloatAnimationCurve()) 965 EXPECT_EQ(TimeDeltaForTesting(), animation->time_offset());
1107 .WillOnce(Return(mockCurvePtr)); 966 EXPECT_EQ(CompositorAnimation::Direction::NORMAL, animation->direction());
1108 967 EXPECT_EQ(1.0, animation->playback_rate());
1109 usesMockCurve += EXPECT_CALL(*mockCurvePtr, addLinearKeyframe(CompositorFloa tKeyframe(0.0, 2.0))); 968 EXPECT_EQ(CompositorAnimation::FillMode::NONE, animation->fill_mode());
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 } 969 }
1138 970
1139 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationWithTiming Function) 971 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationWithTiming Function)
1140 { 972 {
1141 // KeyframeEffect to convert 973 // KeyframeEffect to convert
1142 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel( 974 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel(
1143 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0 ).get(), 0), 975 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0 ).get(), 0),
1144 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0 ).get(), 1.0)); 976 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0 ).get(), 1.0));
1145 977
1146 m_timing.timingFunction = m_cubicCustomTimingFunction; 978 m_timing.timingFunction = m_cubicCustomTimingFunction;
1147 979
1148 // Curve is created 980 std::unique_ptr<CcAnimationForTesting> animation = convertToCompositorAnimat ion(*effect);
1149 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock;
1150 ExpectationSet usesMockCurve;
1151 EXPECT_CALL(*m_mockCompositorFactory, createFloatAnimationCurve())
1152 .WillOnce(Return(mockCurvePtr));
1153 981
1154 usesMockCurve += EXPECT_CALL(*mockCurvePtr, addLinearKeyframe(CompositorFloa tKeyframe(0.0, 2.0))); 982 const CcKeyframedFloatAnimationCurveForTesting* keyframedFloatCurve = ToFloa tCurve(animation.get());
1155 usesMockCurve += EXPECT_CALL(*mockCurvePtr, addCubicBezierKeyframe(Composito rFloatKeyframe(1.0, 5.0), CubicBezierTimingFunction::EaseType::EASE)); 983 DCHECK_EQ(2UL, keyframedFloatCurve->keyframes_for_testing().size());
1156 usesMockCurve += EXPECT_CALL(*mockCurvePtr, setCubicBezierTimingFunction(1, 2, 3, 4));
1157 984
1158 // Create animation 985 auto curve_timing_function = ToCubicBezier(keyframedFloatCurve->timing_funct ion_for_testing());
1159 WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMoc k(CompositorTargetProperty::OPACITY); 986 DCHECK(curve_timing_function);
1160 ExpectationSet usesMockAnimation; 987 EXPECT_EQ(CubicBezierTimingFunction::EaseType::CUSTOM, curve_timing_function ->ease_type());
1161 988
1162 usesMockCurve += EXPECT_CALL(*m_mockCompositorFactory, createAnimation(Ref(* mockCurvePtr), CompositorTargetProperty::OPACITY, _, _)) 989 const CcFloatKeyframeForTesting* keyframe1 = keyframedFloatCurve->keyframes_ for_testing()[0].get();
1163 .WillOnce(Return(mockAnimationPtr)); 990 EXPECT_EQ(TimeDeltaForTesting(), keyframe1->Time());
991 EXPECT_EQ(2.0f, keyframe1->Value());
992 EXPECT_FALSE(keyframe1->timing_function());
1164 993
1165 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(1)); 994 const CcFloatKeyframeForTesting* keyframe2 = keyframedFloatCurve->keyframes_ for_testing()[1].get();
1166 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(0.0)); 995 EXPECT_EQ(TimeDeltaForTesting::FromSecondsD(1.0), keyframe2->Time());
1167 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setDirection(CompositorA nimation::Direction::NORMAL)); 996 EXPECT_EQ(5.0f, keyframe2->Value());
1168 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setPlaybackRate(1)); 997 const CcCubicBezierTimingFunctionForTesting* cubic2 = ToCubicBezier(keyframe 2->timing_function());
1169 998 EXPECT_EQ(CubicBezierTimingFunction::EaseType::EASE, cubic2->ease_type());
1170 EXPECT_CALL(*mockAnimationPtr, delete_())
1171 .Times(1)
1172 .After(usesMockAnimation);
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 } 999 }
1183 1000
1184 TEST_F(AnimationCompositorAnimationsTest, CancelIncompatibleCompositorAnimations ) 1001 TEST_F(AnimationCompositorAnimationsTest, cancelIncompatibleCompositorAnimations )
1185 { 1002 {
1186 Persistent<Element> element = m_document->createElement("shared", ASSERT_NO_ EXCEPTION); 1003 Persistent<Element> element = m_document->createElement("shared", ASSERT_NO_ EXCEPTION);
1187 1004
1188 LayoutObjectProxy* layoutObject = LayoutObjectProxy::create(element.get()); 1005 LayoutObjectProxy* layoutObject = LayoutObjectProxy::create(element.get());
1189 element->setLayoutObject(layoutObject); 1006 element->setLayoutObject(layoutObject);
1190 1007
1191 AnimatableValueKeyframeVector keyFrames; 1008 AnimatableValueKeyframeVector keyFrames;
1192 keyFrames.append(createDefaultKeyframe(CSSPropertyOpacity, EffectModel::Comp ositeReplace, 0.0).get()); 1009 keyFrames.append(createDefaultKeyframe(CSSPropertyOpacity, EffectModel::Comp ositeReplace, 0.0).get());
1193 keyFrames.append(createDefaultKeyframe(CSSPropertyOpacity, EffectModel::Comp ositeReplace, 1.0).get()); 1010 keyFrames.append(createDefaultKeyframe(CSSPropertyOpacity, EffectModel::Comp ositeReplace, 1.0).get());
1194 EffectModel* animationEffect1 = AnimatableValueKeyframeEffectModel::create(k eyFrames); 1011 EffectModel* animationEffect1 = AnimatableValueKeyframeEffectModel::create(k eyFrames);
(...skipping 30 matching lines...) Expand all
1225 simulateFrame(1.); 1042 simulateFrame(1.);
1226 1043
1227 element->setLayoutObject(nullptr); 1044 element->setLayoutObject(nullptr);
1228 LayoutObjectProxy::dispose(layoutObject); 1045 LayoutObjectProxy::dispose(layoutObject);
1229 1046
1230 ThreadHeap::collectAllGarbage(); 1047 ThreadHeap::collectAllGarbage();
1231 EXPECT_TRUE(element->elementAnimations()->animations().isEmpty()); 1048 EXPECT_TRUE(element->elementAnimations()->animations().isEmpty());
1232 } 1049 }
1233 1050
1234 } // namespace blink 1051 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698