Chromium Code Reviews| Index: third_party/WebKit/Source/core/animation/CompositorAnimationsTest.cpp |
| diff --git a/third_party/WebKit/Source/core/animation/CompositorAnimationsTest.cpp b/third_party/WebKit/Source/core/animation/CompositorAnimationsTest.cpp |
| index af2f65d14d86689eda73d2959e44a5c928158d2b..477f9fe39c5bea1e73ea063dcc946c51976ae3e0 100644 |
| --- a/third_party/WebKit/Source/core/animation/CompositorAnimationsTest.cpp |
| +++ b/third_party/WebKit/Source/core/animation/CompositorAnimationsTest.cpp |
| @@ -34,7 +34,6 @@ |
| #include "core/animation/Animation.h" |
| #include "core/animation/AnimationTimeline.h" |
| #include "core/animation/CompositorAnimationsImpl.h" |
| -#include "core/animation/CompositorAnimationsTestHelper.h" |
| #include "core/animation/CompositorPendingAnimations.h" |
| #include "core/animation/ElementAnimations.h" |
| #include "core/animation/KeyframeEffect.h" |
| @@ -46,12 +45,13 @@ |
| #include "core/layout/LayoutObject.h" |
| #include "core/testing/DummyPageHolder.h" |
| #include "platform/animation/CompositorAnimation.h" |
| +#include "platform/animation/CompositorFloatKeyframe.h" |
| #include "platform/geometry/FloatBox.h" |
| #include "platform/geometry/IntSize.h" |
| #include "platform/graphics/filters/FilterOperations.h" |
| +#include "platform/testing/CompositorAnimationsTestUtils.h" |
| #include "platform/transforms/TransformOperations.h" |
| #include "platform/transforms/TranslateTransformOperation.h" |
| -#include "testing/gmock/include/gmock/gmock.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| #include "wtf/HashFunctions.h" |
| #include "wtf/OwnPtr.h" |
| @@ -61,12 +61,20 @@ |
| namespace blink { |
| -using ::testing::ExpectationSet; |
| -using ::testing::Ref; |
| -using ::testing::Return; |
| -using ::testing::_; |
| +// 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
|
| +// for it. |
| +bool operator==(const CompositorFloatKeyframe& a, const CompositorFloatKeyframe& b) |
| +{ |
| + return a.time == b.time && a.value == b.value; |
| +} |
| + |
| +void PrintTo(const CompositorFloatKeyframe& frame, ::std::ostream* os) |
| +{ |
| + *os << "CompositorFloatKeyframe@" << &frame << "(" << frame.time << ", " << frame.value << ")"; |
| +} |
| + |
| -class AnimationCompositorAnimationsTest : public AnimationCompositorAnimationsTestBase { |
| +class AnimationCompositorAnimationsTest : public ::testing::Test { |
| protected: |
| RefPtr<TimingFunction> m_linearTimingFunction; |
| RefPtr<TimingFunction> m_cubicEaseTimingFunction; |
| @@ -84,15 +92,9 @@ protected: |
| Persistent<Element> m_element; |
| Persistent<AnimationTimeline> m_timeline; |
| OwnPtr<DummyPageHolder> m_pageHolder; |
| - CompositorFactoryMock* m_mockCompositorFactory; |
| void SetUp() override |
| { |
| - AnimationCompositorAnimationsTestBase::SetUp(); |
| - |
| - m_mockCompositorFactory = new CompositorFactoryMock(); |
| - CompositorFactory::initializeForTesting(adoptPtr(m_mockCompositorFactory)); |
| - |
| m_linearTimingFunction = LinearTimingFunction::shared(); |
| m_cubicEaseTimingFunction = CubicBezierTimingFunction::preset(CubicBezierTimingFunction::EaseType::EASE); |
| m_cubicCustomTimingFunction = CubicBezierTimingFunction::create(1, 2, 3, 4); |
| @@ -110,27 +112,15 @@ protected: |
| m_keyframeVector5 = createCompositableFloatKeyframeVector(5); |
| m_keyframeAnimationEffect5 = AnimatableValueKeyframeEffectModel::create(*m_keyframeVector5); |
| - EXPECT_CALL(*m_mockCompositorFactory, createAnimationTimeline()) |
| - .WillOnce(Return(new WebCompositorAnimationTimelineMock())); |
| - |
| m_pageHolder = DummyPageHolder::create(); |
| m_document = &m_pageHolder->document(); |
| m_document->animationClock().resetTimeForTesting(); |
| - EXPECT_CALL(*m_mockCompositorFactory, createAnimationTimeline()) |
| - .WillOnce(Return(new WebCompositorAnimationTimelineMock())); |
| - |
| m_timeline = AnimationTimeline::create(m_document.get()); |
| m_timeline->resetForTesting(); |
| m_element = m_document->createElement("test", ASSERT_NO_EXCEPTION); |
| } |
| - void TearDown() override |
| - { |
| - m_mockCompositorFactory = nullptr; |
| - CompositorFactory::shutdown(); |
| - } |
| - |
| public: |
| bool convertTimingForCompositor(const Timing& t, CompositorAnimationsImpl::CompositorTiming& out) |
| { |
| @@ -142,11 +132,11 @@ public: |
| } |
| void getAnimationOnCompositor(Timing& timing, AnimatableValueKeyframeEffectModel& effect, Vector<OwnPtr<CompositorAnimation>>& animations) |
| { |
| - return getAnimationOnCompositor(timing, effect, animations, 1); |
| + getAnimationOnCompositor(timing, effect, animations, 1); |
| } |
| void getAnimationOnCompositor(Timing& timing, AnimatableValueKeyframeEffectModel& effect, Vector<OwnPtr<CompositorAnimation>>& animations, double playerPlaybackRate) |
| { |
| - return CompositorAnimationsImpl::getAnimationOnCompositor(timing, 0, std::numeric_limits<double>::quiet_NaN(), 0, effect, animations, playerPlaybackRate); |
| + CompositorAnimationsImpl::getAnimationOnCompositor(timing, 0, std::numeric_limits<double>::quiet_NaN(), 0, effect, animations, playerPlaybackRate); |
| } |
| bool getAnimationBounds(FloatBox& boundingBox, const EffectModel& effect, double minValue, double maxValue) |
| { |
| @@ -270,6 +260,31 @@ public: |
| m_document->compositorPendingAnimations().update(false); |
| m_timeline->serviceAnimations(TimingUpdateForAnimationFrame); |
| } |
| + |
| + std::unique_ptr<CcAnimationForTesting> convertToCompositorAnimation(AnimatableValueKeyframeEffectModel& effect, double playerPlaybackRate) |
| + { |
| + Vector<OwnPtr<CompositorAnimation>> result; |
| + getAnimationOnCompositor(m_timing, effect, result, playerPlaybackRate); |
| + 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.
|
| + return result[0]->passAnimation(); |
| + } |
| + |
| + std::unique_ptr<CcAnimationForTesting> convertToCompositorAnimation(AnimatableValueKeyframeEffectModel& effect) |
| + { |
| + return convertToCompositorAnimation(effect, 1.0); |
| + } |
| + |
| + const CcKeyframedFloatAnimationCurveForTesting* ToFloatCurve(const CcAnimationForTesting* animation) |
| + { |
| + const CcAnimationCurveForTesting* curve = animation->curve(); |
| + DCHECK_EQ(CcAnimationCurveForTesting::FLOAT, curve->Type()); |
| + return static_cast<const CcKeyframedFloatAnimationCurveForTesting*>(curve->ToFloatAnimationCurve()); |
| + } |
| + |
| + const CcCubicBezierTimingFunctionForTesting* ToCubicBezier(const CcTimingFunctionForTesting* timingFunction) |
| + { |
| + return static_cast<const CcCubicBezierTimingFunctionForTesting*>(timingFunction); |
| + } |
| }; |
| class LayoutObjectProxy : public LayoutObject { |
| @@ -656,41 +671,26 @@ TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimation) |
| AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel( |
| createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0).get(), 0), |
| createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0).get(), 1.0)); |
| - // -- |
| - |
| - // Curve is created |
| - WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; |
| - ExpectationSet usesMockCurve; |
| - EXPECT_CALL(*m_mockCompositorFactory, createFloatAnimationCurve()) |
| - .WillOnce(Return(mockCurvePtr)); |
| - |
| - usesMockCurve += EXPECT_CALL(*mockCurvePtr, addLinearKeyframe(CompositorFloatKeyframe(0.0, 2.0))); |
| - usesMockCurve += EXPECT_CALL(*mockCurvePtr, addCubicBezierKeyframe(CompositorFloatKeyframe(1.0, 5.0), CubicBezierTimingFunction::EaseType::EASE)); |
| - |
| - // Create animation |
| - WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMock(CompositorTargetProperty::OPACITY); |
| - ExpectationSet usesMockAnimation; |
| - |
| - usesMockCurve += EXPECT_CALL(*m_mockCompositorFactory, createAnimation(Ref(*mockCurvePtr), CompositorTargetProperty::OPACITY, _, _)) |
| - .WillOnce(Return(mockAnimationPtr)); |
| - |
| - usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(1)); |
| - usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(0.0)); |
| - usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setDirection(CompositorAnimation::Direction::NORMAL)); |
| - usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setPlaybackRate(1)); |
| - |
| - EXPECT_CALL(*mockAnimationPtr, delete_()) |
| - .Times(1) |
| - .After(usesMockAnimation); |
| - EXPECT_CALL(*mockCurvePtr, delete_()) |
| - .Times(1) |
| - .After(usesMockCurve); |
| - |
| - // Go! |
| - Vector<OwnPtr<CompositorAnimation>> result; |
| - getAnimationOnCompositor(m_timing, *effect, result); |
| - EXPECT_EQ(1U, result.size()); |
| - result[0].reset(); |
| + |
| + std::unique_ptr<CcAnimationForTesting> animation = convertToCompositorAnimation(*effect); |
| + EXPECT_EQ(CompositorTargetProperty::OPACITY, animation->target_property()); |
| + EXPECT_EQ(1.0, animation->iterations()); |
| + EXPECT_EQ(TimeDeltaForTesting(), animation->time_offset()); |
| + EXPECT_EQ(CompositorAnimation::Direction::NORMAL, animation->direction()); |
| + EXPECT_EQ(1.0, animation->playback_rate()); |
| + |
| + const CcKeyframedFloatAnimationCurveForTesting* keyframedFloatCurve = ToFloatCurve(animation.get()); |
| + |
| + DCHECK_EQ(2UL, keyframedFloatCurve->keyframes_for_testing().size()); |
| + const CcFloatKeyframeForTesting* keyframe1 = keyframedFloatCurve->keyframes_for_testing()[0].get(); |
| + const CcFloatKeyframeForTesting* keyframe2 = keyframedFloatCurve->keyframes_for_testing()[1].get(); |
| + EXPECT_EQ(TimeDeltaForTesting(), keyframe1->Time()); |
| + EXPECT_EQ(2.0f, keyframe1->Value()); |
| + |
| + EXPECT_EQ(TimeDeltaForTesting::FromSecondsD(1.0), keyframe2->Time()); |
| + EXPECT_EQ(5.0f, keyframe2->Value()); |
| + const CcCubicBezierTimingFunctionForTesting* cubic = ToCubicBezier(keyframe2->timing_function()); |
| + EXPECT_EQ(CubicBezierTimingFunction::EaseType::EASE, cubic->ease_type()); |
| } |
| TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationDuration) |
| @@ -700,42 +700,15 @@ TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationDuration) |
| createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0).get(), 0), |
| createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0).get(), 1.0)); |
| - m_timing.iterationDuration = 10.0; |
| - // -- |
| - |
| - // Curve is created |
| - WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; |
| - ExpectationSet usesMockCurve; |
| - EXPECT_CALL(*m_mockCompositorFactory, createFloatAnimationCurve()) |
| - .WillOnce(Return(mockCurvePtr)); |
| - |
| - usesMockCurve += EXPECT_CALL(*mockCurvePtr, addLinearKeyframe(CompositorFloatKeyframe(0.0, 2.0))); |
| - usesMockCurve += EXPECT_CALL(*mockCurvePtr, addCubicBezierKeyframe(CompositorFloatKeyframe(10.0, 5.0), CubicBezierTimingFunction::EaseType::EASE)); |
| - |
| - // Create animation |
| - WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMock(CompositorTargetProperty::OPACITY); |
| - ExpectationSet usesMockAnimation; |
| - |
| - usesMockCurve += EXPECT_CALL(*m_mockCompositorFactory, createAnimation(Ref(*mockCurvePtr), CompositorTargetProperty::OPACITY, _, _)) |
| - .WillOnce(Return(mockAnimationPtr)); |
| - |
| - usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(1)); |
| - usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(0.0)); |
| - usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setDirection(CompositorAnimation::Direction::NORMAL)); |
| - usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setPlaybackRate(1)); |
| - |
| - EXPECT_CALL(*mockAnimationPtr, delete_()) |
| - .Times(1) |
| - .After(usesMockAnimation); |
| - EXPECT_CALL(*mockCurvePtr, delete_()) |
| - .Times(1) |
| - .After(usesMockCurve); |
| - |
| - // Go! |
| - Vector<OwnPtr<CompositorAnimation>> result; |
| - getAnimationOnCompositor(m_timing, *effect, result); |
| - EXPECT_EQ(1U, result.size()); |
| - result[0].reset(); |
| + const double duration = 10.0; |
| + m_timing.iterationDuration = duration; |
| + |
| + std::unique_ptr<CcAnimationForTesting> animation = convertToCompositorAnimation(*effect); |
| + const CcKeyframedFloatAnimationCurveForTesting* keyframedFloatCurve = ToFloatCurve(animation.get()); |
| + |
| + DCHECK_EQ(2UL, keyframedFloatCurve->keyframes_for_testing().size()); |
| + const CcFloatKeyframeForTesting* keyframe2 = keyframedFloatCurve->keyframes_for_testing()[1].get(); |
| + EXPECT_EQ(TimeDeltaForTesting::FromSecondsD(duration), keyframe2->Time()); |
| } |
| TEST_F(AnimationCompositorAnimationsTest, createMultipleKeyframeOpacityAnimationLinear) |
| @@ -750,44 +723,37 @@ TEST_F(AnimationCompositorAnimationsTest, createMultipleKeyframeOpacityAnimation |
| m_timing.iterationCount = 5; |
| m_timing.direction = Timing::PlaybackDirectionAlternate; |
| m_timing.playbackRate = 2.0; |
| - // -- |
| - |
| - // Curve is created |
| - WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock(); |
| - ExpectationSet usesMockCurve; |
| - |
| - EXPECT_CALL(*m_mockCompositorFactory, createFloatAnimationCurve()) |
| - .WillOnce(Return(mockCurvePtr)); |
| - |
| - usesMockCurve += EXPECT_CALL(*mockCurvePtr, addLinearKeyframe(CompositorFloatKeyframe(0.0, 2.0))); |
| - usesMockCurve += EXPECT_CALL(*mockCurvePtr, addLinearKeyframe(CompositorFloatKeyframe(0.25, -1.0))); |
| - usesMockCurve += EXPECT_CALL(*mockCurvePtr, addLinearKeyframe(CompositorFloatKeyframe(0.5, 20.0))); |
| - usesMockCurve += EXPECT_CALL(*mockCurvePtr, addCubicBezierKeyframe(CompositorFloatKeyframe(1.0, 5.0), CubicBezierTimingFunction::EaseType::EASE)); |
| - |
| - // KeyframeEffect is created |
| - WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMock(CompositorTargetProperty::OPACITY); |
| - ExpectationSet usesMockAnimation; |
| - |
| - usesMockCurve += EXPECT_CALL(*m_mockCompositorFactory, createAnimation(Ref(*mockCurvePtr), CompositorTargetProperty::OPACITY, _, _)) |
| - .WillOnce(Return(mockAnimationPtr)); |
| - |
| - usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(5)); |
| - usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(0.0)); |
| - usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setDirection(CompositorAnimation::Direction::ALTERNATE_NORMAL)); |
| - usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setPlaybackRate(2.0)); |
| - |
| - EXPECT_CALL(*mockAnimationPtr, delete_()) |
| - .Times(1) |
| - .After(usesMockAnimation); |
| - EXPECT_CALL(*mockCurvePtr, delete_()) |
| - .Times(1) |
| - .After(usesMockCurve); |
| - |
| - // Go! |
| - Vector<OwnPtr<CompositorAnimation>> result; |
| - getAnimationOnCompositor(m_timing, *effect, result); |
| - EXPECT_EQ(1U, result.size()); |
| - result[0].reset(); |
| + |
| + std::unique_ptr<CcAnimationForTesting> animation = convertToCompositorAnimation(*effect); |
| + EXPECT_EQ(CompositorTargetProperty::OPACITY, animation->target_property()); |
| + EXPECT_EQ(5.0, animation->iterations()); |
| + EXPECT_EQ(TimeDeltaForTesting(), animation->time_offset()); |
| + EXPECT_EQ(CompositorAnimation::Direction::ALTERNATE_NORMAL, animation->direction()); |
| + EXPECT_EQ(2.0, animation->playback_rate()); |
| + |
| + const CcKeyframedFloatAnimationCurveForTesting* keyframedFloatCurve = ToFloatCurve(animation.get()); |
| + DCHECK_EQ(4UL, keyframedFloatCurve->keyframes_for_testing().size()); |
| + |
| + const CcFloatKeyframeForTesting* keyframe1 = keyframedFloatCurve->keyframes_for_testing()[0].get(); |
| + EXPECT_EQ(TimeDeltaForTesting(), keyframe1->Time()); |
| + EXPECT_EQ(2.0f, keyframe1->Value()); |
| + EXPECT_FALSE(keyframe1->timing_function()); |
| + |
| + const CcFloatKeyframeForTesting* keyframe2 = keyframedFloatCurve->keyframes_for_testing()[1].get(); |
| + EXPECT_EQ(TimeDeltaForTesting::FromSecondsD(0.25), keyframe2->Time()); |
| + EXPECT_EQ(-1.0f, keyframe2->Value()); |
| + EXPECT_FALSE(keyframe2->timing_function()); |
| + |
| + const CcFloatKeyframeForTesting* keyframe3 = keyframedFloatCurve->keyframes_for_testing()[2].get(); |
| + EXPECT_EQ(TimeDeltaForTesting::FromSecondsD(0.5), keyframe3->Time()); |
| + EXPECT_EQ(20.0f, keyframe3->Value()); |
| + EXPECT_FALSE(keyframe3->timing_function()); |
| + |
| + const CcFloatKeyframeForTesting* keyframe4 = keyframedFloatCurve->keyframes_for_testing()[3].get(); |
| + EXPECT_EQ(TimeDeltaForTesting::FromSecondsD(1.0), keyframe4->Time()); |
| + EXPECT_EQ(5.0f, keyframe4->Value()); |
| + const CcCubicBezierTimingFunctionForTesting* cubic = ToCubicBezier(keyframe4->timing_function()); |
| + EXPECT_EQ(CubicBezierTimingFunction::EaseType::EASE, cubic->ease_type()); |
| } |
| TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationStartDelay) |
| @@ -797,44 +763,24 @@ TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationStartDelay |
| createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0).get(), 0), |
| createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0).get(), 1.0)); |
| + const double startDelay = 3.25; |
| + |
| m_timing.iterationCount = 5.0; |
| m_timing.iterationDuration = 1.75; |
| - m_timing.startDelay = 3.25; |
| - // -- |
| - |
| - // Curve is created |
| - WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; |
| - ExpectationSet usesMockCurve; |
| - EXPECT_CALL(*m_mockCompositorFactory, createFloatAnimationCurve()) |
| - .WillOnce(Return(mockCurvePtr)); |
| - |
| - usesMockCurve += EXPECT_CALL(*mockCurvePtr, addLinearKeyframe(CompositorFloatKeyframe(0.0, 2.0))); |
| - usesMockCurve += EXPECT_CALL(*mockCurvePtr, addCubicBezierKeyframe(CompositorFloatKeyframe(1.75, 5.0), CubicBezierTimingFunction::EaseType::EASE)); |
| - |
| - // Create animation |
| - WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMock(CompositorTargetProperty::OPACITY); |
| - ExpectationSet usesMockAnimation; |
| - |
| - usesMockCurve += EXPECT_CALL(*m_mockCompositorFactory, createAnimation(Ref(*mockCurvePtr), CompositorTargetProperty::OPACITY, _, _)) |
| - .WillOnce(Return(mockAnimationPtr)); |
| - |
| - usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(5)); |
| - usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(-3.25)); |
| - usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setDirection(CompositorAnimation::Direction::NORMAL)); |
| - usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setPlaybackRate(1)); |
| - |
| - EXPECT_CALL(*mockAnimationPtr, delete_()) |
| - .Times(1) |
| - .After(usesMockAnimation); |
| - EXPECT_CALL(*mockCurvePtr, delete_()) |
| - .Times(1) |
| - .After(usesMockCurve); |
| - |
| - // Go! |
| - Vector<OwnPtr<CompositorAnimation>> result; |
| - getAnimationOnCompositor(m_timing, *effect, result); |
| - EXPECT_EQ(1U, result.size()); |
| - result[0].reset(); |
| + m_timing.startDelay = startDelay; |
| + |
| + std::unique_ptr<CcAnimationForTesting> animation = convertToCompositorAnimation(*effect); |
| + |
| + EXPECT_EQ(CompositorTargetProperty::OPACITY, animation->target_property()); |
| + EXPECT_EQ(5.0, animation->iterations()); |
| + EXPECT_EQ(TimeDeltaForTesting::FromSecondsD(-startDelay), animation->time_offset()); |
| + |
| + const CcKeyframedFloatAnimationCurveForTesting* keyframedFloatCurve = ToFloatCurve(animation.get()); |
| + DCHECK_EQ(2UL, keyframedFloatCurve->keyframes_for_testing().size()); |
| + |
| + const CcFloatKeyframeForTesting* keyframe2 = keyframedFloatCurve->keyframes_for_testing()[1].get(); |
| + EXPECT_EQ(TimeDeltaForTesting::FromSecondsD(1.75), keyframe2->Time()); |
| + EXPECT_EQ(5.0f, keyframe2->Value()); |
| } |
| TEST_F(AnimationCompositorAnimationsTest, createMultipleKeyframeOpacityAnimationChained) |
| @@ -854,44 +800,39 @@ TEST_F(AnimationCompositorAnimationsTest, createMultipleKeyframeOpacityAnimation |
| m_timing.iterationDuration = 2.0; |
| m_timing.iterationCount = 10; |
| m_timing.direction = Timing::PlaybackDirectionAlternate; |
| - // -- |
| - |
| - // Curve is created |
| - WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock(); |
| - ExpectationSet usesMockCurve; |
| - |
| - EXPECT_CALL(*m_mockCompositorFactory, createFloatAnimationCurve()) |
| - .WillOnce(Return(mockCurvePtr)); |
| - |
| - usesMockCurve += EXPECT_CALL(*mockCurvePtr, addCubicBezierKeyframe(CompositorFloatKeyframe(0.0, 2.0), CubicBezierTimingFunction::EaseType::EASE)); |
| - usesMockCurve += EXPECT_CALL(*mockCurvePtr, addLinearKeyframe(CompositorFloatKeyframe(0.5, -1.0))); |
| - usesMockCurve += EXPECT_CALL(*mockCurvePtr, addCubicBezierKeyframe(CompositorFloatKeyframe(1.0, 20.0), 1.0, 2.0, 3.0, 4.0)); |
| - usesMockCurve += EXPECT_CALL(*mockCurvePtr, addCubicBezierKeyframe(CompositorFloatKeyframe(2.0, 5.0), CubicBezierTimingFunction::EaseType::EASE)); |
| - |
| - // KeyframeEffect is created |
| - WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMock(CompositorTargetProperty::OPACITY); |
| - ExpectationSet usesMockAnimation; |
| - |
| - usesMockCurve += EXPECT_CALL(*m_mockCompositorFactory, createAnimation(Ref(*mockCurvePtr), CompositorTargetProperty::OPACITY, _, _)) |
| - .WillOnce(Return(mockAnimationPtr)); |
| - |
| - usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(10)); |
| - usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(0.0)); |
| - usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setDirection(CompositorAnimation::Direction::ALTERNATE_NORMAL)); |
| - usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setPlaybackRate(1)); |
| - |
| - EXPECT_CALL(*mockAnimationPtr, delete_()) |
| - .Times(1) |
| - .After(usesMockAnimation); |
| - EXPECT_CALL(*mockCurvePtr, delete_()) |
| - .Times(1) |
| - .After(usesMockCurve); |
| - |
| - // Go! |
| - Vector<OwnPtr<CompositorAnimation>> result; |
| - getAnimationOnCompositor(m_timing, *effect, result); |
| - EXPECT_EQ(1U, result.size()); |
| - result[0].reset(); |
| + |
| + std::unique_ptr<CcAnimationForTesting> animation = convertToCompositorAnimation(*effect); |
| + EXPECT_EQ(CompositorTargetProperty::OPACITY, animation->target_property()); |
| + EXPECT_EQ(10.0, animation->iterations()); |
| + EXPECT_EQ(TimeDeltaForTesting(), animation->time_offset()); |
| + EXPECT_EQ(CompositorAnimation::Direction::ALTERNATE_NORMAL, animation->direction()); |
| + EXPECT_EQ(1.0, animation->playback_rate()); |
| + |
| + const CcKeyframedFloatAnimationCurveForTesting* keyframedFloatCurve = ToFloatCurve(animation.get()); |
| + DCHECK_EQ(4UL, keyframedFloatCurve->keyframes_for_testing().size()); |
| + |
| + const CcFloatKeyframeForTesting* keyframe1 = keyframedFloatCurve->keyframes_for_testing()[0].get(); |
| + EXPECT_EQ(TimeDeltaForTesting(), keyframe1->Time()); |
| + EXPECT_EQ(2.0f, keyframe1->Value()); |
| + const CcCubicBezierTimingFunctionForTesting* cubic1 = ToCubicBezier(keyframe1->timing_function()); |
| + EXPECT_EQ(CubicBezierTimingFunction::EaseType::EASE, cubic1->ease_type()); |
| + |
| + const CcFloatKeyframeForTesting* keyframe2 = keyframedFloatCurve->keyframes_for_testing()[1].get(); |
| + EXPECT_EQ(TimeDeltaForTesting::FromSecondsD(0.5), keyframe2->Time()); |
| + EXPECT_EQ(-1.0f, keyframe2->Value()); |
| + EXPECT_FALSE(keyframe2->timing_function()); |
| + |
| + const CcFloatKeyframeForTesting* keyframe3 = keyframedFloatCurve->keyframes_for_testing()[2].get(); |
| + EXPECT_EQ(TimeDeltaForTesting::FromSecondsD(1.0), keyframe3->Time()); |
| + EXPECT_EQ(20.0f, keyframe3->Value()); |
| + const CcCubicBezierTimingFunctionForTesting* cubic3 = ToCubicBezier(keyframe3->timing_function()); |
| + EXPECT_EQ(CubicBezierTimingFunction::EaseType::CUSTOM, cubic3->ease_type()); |
| + |
| + const CcFloatKeyframeForTesting* keyframe4 = keyframedFloatCurve->keyframes_for_testing()[3].get(); |
| + EXPECT_EQ(TimeDeltaForTesting::FromSecondsD(2.0), keyframe4->Time()); |
| + EXPECT_EQ(5.0f, keyframe4->Value()); |
| + const CcCubicBezierTimingFunctionForTesting* cubic4 = ToCubicBezier(keyframe4->timing_function()); |
| + EXPECT_EQ(CubicBezierTimingFunction::EaseType::EASE, cubic4->ease_type()); |
| } |
| TEST_F(AnimationCompositorAnimationsTest, createReversedOpacityAnimation) |
| @@ -912,44 +853,40 @@ TEST_F(AnimationCompositorAnimationsTest, createReversedOpacityAnimation) |
| m_timing.timingFunction = m_linearTimingFunction.get(); |
| m_timing.iterationCount = 10; |
| m_timing.direction = Timing::PlaybackDirectionAlternateReverse; |
| - // -- |
| - |
| - // Curve is created |
| - WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock(); |
| - ExpectationSet usesMockCurve; |
| - |
| - EXPECT_CALL(*m_mockCompositorFactory, createFloatAnimationCurve()) |
| - .WillOnce(Return(mockCurvePtr)); |
| - |
| - usesMockCurve += EXPECT_CALL(*mockCurvePtr, addCubicBezierKeyframe(CompositorFloatKeyframe(0.0, 2.0), CubicBezierTimingFunction::EaseType::EASE_IN)); |
| - usesMockCurve += EXPECT_CALL(*mockCurvePtr, addLinearKeyframe(CompositorFloatKeyframe(0.25, -1.0))); |
| - usesMockCurve += EXPECT_CALL(*mockCurvePtr, addCubicBezierKeyframe(CompositorFloatKeyframe(0.5, 20.0), 0.0, 0.0, 0.0, 1.0)); |
| - usesMockCurve += EXPECT_CALL(*mockCurvePtr, addCubicBezierKeyframe(CompositorFloatKeyframe(1.0, 5.0), CubicBezierTimingFunction::EaseType::EASE)); |
| - |
| - // Create the animation |
| - WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMock(CompositorTargetProperty::OPACITY); |
| - ExpectationSet usesMockAnimation; |
| - |
| - usesMockCurve += EXPECT_CALL(*m_mockCompositorFactory, createAnimation(Ref(*mockCurvePtr), CompositorTargetProperty::OPACITY, _, _)) |
| - .WillOnce(Return(mockAnimationPtr)); |
| - |
| - usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(10)); |
| - usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(0.0)); |
| - usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setDirection(CompositorAnimation::Direction::ALTERNATE_REVERSE)); |
| - usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setPlaybackRate(1)); |
| - |
| - EXPECT_CALL(*mockAnimationPtr, delete_()) |
| - .Times(1) |
| - .After(usesMockAnimation); |
| - EXPECT_CALL(*mockCurvePtr, delete_()) |
| - .Times(1) |
| - .After(usesMockCurve); |
| - |
| - // Go! |
| - Vector<OwnPtr<CompositorAnimation>> result; |
| - getAnimationOnCompositor(m_timing, *effect, result); |
| - EXPECT_EQ(1U, result.size()); |
| - result[0].reset(); |
| + |
| + std::unique_ptr<CcAnimationForTesting> animation = convertToCompositorAnimation(*effect); |
| + EXPECT_EQ(CompositorTargetProperty::OPACITY, animation->target_property()); |
| + EXPECT_EQ(10.0, animation->iterations()); |
| + EXPECT_EQ(TimeDeltaForTesting(), animation->time_offset()); |
| + EXPECT_EQ(CompositorAnimation::Direction::ALTERNATE_REVERSE, animation->direction()); |
| + EXPECT_EQ(1.0, animation->playback_rate()); |
| + |
| + const CcKeyframedFloatAnimationCurveForTesting* keyframedFloatCurve = ToFloatCurve(animation.get()); |
| + DCHECK_EQ(4UL, keyframedFloatCurve->keyframes_for_testing().size()); |
| + EXPECT_FALSE(keyframedFloatCurve->timing_function_for_testing()); |
| + |
| + const CcFloatKeyframeForTesting* keyframe1 = keyframedFloatCurve->keyframes_for_testing()[0].get(); |
| + EXPECT_EQ(TimeDeltaForTesting(), keyframe1->Time()); |
| + EXPECT_EQ(2.0f, keyframe1->Value()); |
| + const CcCubicBezierTimingFunctionForTesting* cubic1 = ToCubicBezier(keyframe1->timing_function()); |
| + EXPECT_EQ(CubicBezierTimingFunction::EaseType::EASE_IN, cubic1->ease_type()); |
| + |
| + const CcFloatKeyframeForTesting* keyframe2 = keyframedFloatCurve->keyframes_for_testing()[1].get(); |
| + EXPECT_EQ(TimeDeltaForTesting::FromSecondsD(0.25), keyframe2->Time()); |
| + EXPECT_EQ(-1.0f, keyframe2->Value()); |
| + EXPECT_FALSE(keyframe2->timing_function()); |
| + |
| + const CcFloatKeyframeForTesting* keyframe3 = keyframedFloatCurve->keyframes_for_testing()[2].get(); |
| + EXPECT_EQ(TimeDeltaForTesting::FromSecondsD(0.5), keyframe3->Time()); |
| + EXPECT_EQ(20.0f, keyframe3->Value()); |
| + const CcCubicBezierTimingFunctionForTesting* cubic3 = ToCubicBezier(keyframe3->timing_function()); |
| + EXPECT_EQ(CubicBezierTimingFunction::EaseType::CUSTOM, cubic3->ease_type()); |
| + |
| + const CcFloatKeyframeForTesting* keyframe4 = keyframedFloatCurve->keyframes_for_testing()[3].get(); |
| + EXPECT_EQ(TimeDeltaForTesting::FromSecondsD(1.0), keyframe4->Time()); |
| + EXPECT_EQ(5.0f, keyframe4->Value()); |
| + const CcCubicBezierTimingFunctionForTesting* cubic4 = ToCubicBezier(keyframe4->timing_function()); |
| + EXPECT_EQ(CubicBezierTimingFunction::EaseType::EASE, cubic4->ease_type()); |
| } |
| TEST_F(AnimationCompositorAnimationsTest, createReversedOpacityAnimationNegativeStartDelay) |
| @@ -959,45 +896,22 @@ TEST_F(AnimationCompositorAnimationsTest, createReversedOpacityAnimationNegative |
| createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0).get(), 0), |
| createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0).get(), 1.0)); |
| + const double negativeStartDelay = -3; |
| + |
| m_timing.iterationCount = 5.0; |
| m_timing.iterationDuration = 1.5; |
| - m_timing.startDelay = -3; |
| + m_timing.startDelay = negativeStartDelay; |
| m_timing.direction = Timing::PlaybackDirectionAlternateReverse; |
| - // -- |
| - |
| - // Curve is created |
| - WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; |
| - ExpectationSet usesMockCurve; |
| - EXPECT_CALL(*m_mockCompositorFactory, createFloatAnimationCurve()) |
| - .WillOnce(Return(mockCurvePtr)); |
| - |
| - usesMockCurve += EXPECT_CALL(*mockCurvePtr, addLinearKeyframe(CompositorFloatKeyframe(0.0, 2.0))); |
| - usesMockCurve += EXPECT_CALL(*mockCurvePtr, addCubicBezierKeyframe(CompositorFloatKeyframe(1.5, 5.0), CubicBezierTimingFunction::EaseType::EASE)); |
| - |
| - // Create animation |
| - WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMock(CompositorTargetProperty::OPACITY); |
| - ExpectationSet usesMockAnimation; |
| - |
| - usesMockCurve += EXPECT_CALL(*m_mockCompositorFactory, createAnimation(Ref(*mockCurvePtr), CompositorTargetProperty::OPACITY, _, _)) |
| - .WillOnce(Return(mockAnimationPtr)); |
| - |
| - usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(5)); |
| - usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(3.0)); |
| - usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setDirection(CompositorAnimation::Direction::ALTERNATE_REVERSE)); |
| - usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setPlaybackRate(1)); |
| - |
| - EXPECT_CALL(*mockAnimationPtr, delete_()) |
| - .Times(1) |
| - .After(usesMockAnimation); |
| - EXPECT_CALL(*mockCurvePtr, delete_()) |
| - .Times(1) |
| - .After(usesMockCurve); |
| - |
| - // Go! |
| - Vector<OwnPtr<CompositorAnimation>> result; |
| - getAnimationOnCompositor(m_timing, *effect, result); |
| - EXPECT_EQ(1U, result.size()); |
| - result[0].reset(); |
| + |
| + std::unique_ptr<CcAnimationForTesting> animation = convertToCompositorAnimation(*effect); |
| + EXPECT_EQ(CompositorTargetProperty::OPACITY, animation->target_property()); |
| + EXPECT_EQ(5.0, animation->iterations()); |
| + EXPECT_EQ(TimeDeltaForTesting::FromSecondsD(-negativeStartDelay), animation->time_offset()); |
| + EXPECT_EQ(CompositorAnimation::Direction::ALTERNATE_REVERSE, animation->direction()); |
| + EXPECT_EQ(1.0, animation->playback_rate()); |
| + |
| + const CcKeyframedFloatAnimationCurveForTesting* keyframedFloatCurve = ToFloatCurve(animation.get()); |
| + DCHECK_EQ(2UL, keyframedFloatCurve->keyframes_for_testing().size()); |
| } |
| TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationPlaybackRates) |
| @@ -1007,43 +921,20 @@ TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationPlaybackRa |
| createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0).get(), 0), |
| createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0).get(), 1.0)); |
| - m_timing.playbackRate = 2; |
| - // -- |
| - |
| - // Curve is created |
| - WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; |
| - ExpectationSet usesMockCurve; |
| - EXPECT_CALL(*m_mockCompositorFactory, createFloatAnimationCurve()) |
| - .WillOnce(Return(mockCurvePtr)); |
| - |
| - usesMockCurve += EXPECT_CALL(*mockCurvePtr, addLinearKeyframe(CompositorFloatKeyframe(0.0, 2.0))); |
| - usesMockCurve += EXPECT_CALL(*mockCurvePtr, addCubicBezierKeyframe(CompositorFloatKeyframe(1.0, 5.0), CubicBezierTimingFunction::EaseType::EASE)); |
| - |
| - // Create animation |
| - WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMock(CompositorTargetProperty::OPACITY); |
| - ExpectationSet usesMockAnimation; |
| - |
| - usesMockCurve += EXPECT_CALL(*m_mockCompositorFactory, createAnimation(Ref(*mockCurvePtr), CompositorTargetProperty::OPACITY, _, _)) |
| - .WillOnce(Return(mockAnimationPtr)); |
| - |
| - usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(1)); |
| - usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(0.0)); |
| - usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setDirection(CompositorAnimation::Direction::NORMAL)); |
| - usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setPlaybackRate(-3)); |
| - |
| - EXPECT_CALL(*mockAnimationPtr, delete_()) |
| - .Times(1) |
| - .After(usesMockAnimation); |
| - EXPECT_CALL(*mockCurvePtr, delete_()) |
| - .Times(1) |
| - .After(usesMockCurve); |
| - |
| - // Go! |
| - Vector<OwnPtr<CompositorAnimation>> result; |
| - // Set player plaback rate also |
| - getAnimationOnCompositor(m_timing, *effect, result, -1.5); |
| - EXPECT_EQ(1U, result.size()); |
| - result[0].reset(); |
| + const double playbackRate = 2; |
| + const double playerPlaybackRate = -1.5; |
| + |
| + m_timing.playbackRate = playbackRate; |
| + |
| + std::unique_ptr<CcAnimationForTesting> animation = convertToCompositorAnimation(*effect, playerPlaybackRate); |
| + EXPECT_EQ(CompositorTargetProperty::OPACITY, animation->target_property()); |
| + EXPECT_EQ(1.0, animation->iterations()); |
| + EXPECT_EQ(TimeDeltaForTesting(), animation->time_offset()); |
| + EXPECT_EQ(CompositorAnimation::Direction::NORMAL, animation->direction()); |
| + EXPECT_EQ(playbackRate * playerPlaybackRate, animation->playback_rate()); |
| + |
| + const CcKeyframedFloatAnimationCurveForTesting* keyframedFloatCurve = ToFloatCurve(animation.get()); |
| + DCHECK_EQ(2UL, keyframedFloatCurve->keyframes_for_testing().size()); |
| } |
| TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationFillModeNone) |
| @@ -1055,40 +946,8 @@ TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationFillModeNo |
| m_timing.fillMode = Timing::FillModeNone; |
| - // Curve is created |
| - WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; |
| - ExpectationSet usesMockCurve; |
| - EXPECT_CALL(*m_mockCompositorFactory, createFloatAnimationCurve()) |
| - .WillOnce(Return(mockCurvePtr)); |
| - |
| - usesMockCurve += EXPECT_CALL(*mockCurvePtr, addLinearKeyframe(CompositorFloatKeyframe(0.0, 2.0))); |
| - usesMockCurve += EXPECT_CALL(*mockCurvePtr, addCubicBezierKeyframe(CompositorFloatKeyframe(1.0, 5.0), CubicBezierTimingFunction::EaseType::EASE)); |
| - |
| - // Create animation |
| - WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMock(CompositorTargetProperty::OPACITY); |
| - ExpectationSet usesMockAnimation; |
| - |
| - usesMockCurve += EXPECT_CALL(*m_mockCompositorFactory, createAnimation(Ref(*mockCurvePtr), CompositorTargetProperty::OPACITY, _, _)) |
| - .WillOnce(Return(mockAnimationPtr)); |
| - |
| - usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(1)); |
| - usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(0.0)); |
| - usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setDirection(CompositorAnimation::Direction::NORMAL)); |
| - usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setPlaybackRate(1)); |
| - usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setFillMode(CompositorAnimation::FillMode::NONE)); |
| - |
| - EXPECT_CALL(*mockAnimationPtr, delete_()) |
| - .Times(1) |
| - .After(usesMockAnimation); |
| - EXPECT_CALL(*mockCurvePtr, delete_()) |
| - .Times(1) |
| - .After(usesMockCurve); |
| - |
| - // Go! |
| - Vector<OwnPtr<CompositorAnimation>> result; |
| - getAnimationOnCompositor(m_timing, *effect, result); |
| - EXPECT_EQ(1U, result.size()); |
| - result[0].reset(); |
| + std::unique_ptr<CcAnimationForTesting> animation = convertToCompositorAnimation(*effect); |
| + EXPECT_EQ(CompositorAnimation::FillMode::NONE, animation->fill_mode()); |
| } |
| TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationFillModeAuto) |
| @@ -1100,40 +959,13 @@ TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationFillModeAu |
| m_timing.fillMode = Timing::FillModeAuto; |
| - // Curve is created |
| - WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; |
| - ExpectationSet usesMockCurve; |
| - EXPECT_CALL(*m_mockCompositorFactory, createFloatAnimationCurve()) |
| - .WillOnce(Return(mockCurvePtr)); |
| - |
| - usesMockCurve += EXPECT_CALL(*mockCurvePtr, addLinearKeyframe(CompositorFloatKeyframe(0.0, 2.0))); |
| - usesMockCurve += EXPECT_CALL(*mockCurvePtr, addCubicBezierKeyframe(CompositorFloatKeyframe(1.0, 5.0), CubicBezierTimingFunction::EaseType::EASE)); |
| - |
| - // Create animation |
| - WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMock(CompositorTargetProperty::OPACITY); |
| - ExpectationSet usesMockAnimation; |
| - |
| - usesMockCurve += EXPECT_CALL(*m_mockCompositorFactory, createAnimation(Ref(*mockCurvePtr), CompositorTargetProperty::OPACITY, _, _)) |
| - .WillOnce(Return(mockAnimationPtr)); |
| - |
| - usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(1)); |
| - usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(0.0)); |
| - usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setDirection(CompositorAnimation::Direction::NORMAL)); |
| - usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setPlaybackRate(1)); |
| - usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setFillMode(CompositorAnimation::FillMode::NONE)); |
| - |
| - EXPECT_CALL(*mockAnimationPtr, delete_()) |
| - .Times(1) |
| - .After(usesMockAnimation); |
| - EXPECT_CALL(*mockCurvePtr, delete_()) |
| - .Times(1) |
| - .After(usesMockCurve); |
| - |
| - // Go! |
| - Vector<OwnPtr<CompositorAnimation>> result; |
| - getAnimationOnCompositor(m_timing, *effect, result); |
| - EXPECT_EQ(1U, result.size()); |
| - result[0].reset(); |
| + std::unique_ptr<CcAnimationForTesting> animation = convertToCompositorAnimation(*effect); |
| + EXPECT_EQ(CompositorTargetProperty::OPACITY, animation->target_property()); |
| + EXPECT_EQ(1.0, animation->iterations()); |
| + EXPECT_EQ(TimeDeltaForTesting(), animation->time_offset()); |
| + EXPECT_EQ(CompositorAnimation::Direction::NORMAL, animation->direction()); |
| + EXPECT_EQ(1.0, animation->playback_rate()); |
| + EXPECT_EQ(CompositorAnimation::FillMode::NONE, animation->fill_mode()); |
| } |
| TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationWithTimingFunction) |
| @@ -1145,43 +977,28 @@ TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationWithTiming |
| m_timing.timingFunction = m_cubicCustomTimingFunction; |
| - // Curve is created |
| - WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; |
| - ExpectationSet usesMockCurve; |
| - EXPECT_CALL(*m_mockCompositorFactory, createFloatAnimationCurve()) |
| - .WillOnce(Return(mockCurvePtr)); |
| - |
| - usesMockCurve += EXPECT_CALL(*mockCurvePtr, addLinearKeyframe(CompositorFloatKeyframe(0.0, 2.0))); |
| - usesMockCurve += EXPECT_CALL(*mockCurvePtr, addCubicBezierKeyframe(CompositorFloatKeyframe(1.0, 5.0), CubicBezierTimingFunction::EaseType::EASE)); |
| - usesMockCurve += EXPECT_CALL(*mockCurvePtr, setCubicBezierTimingFunction(1, 2, 3, 4)); |
| - |
| - // Create animation |
| - WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMock(CompositorTargetProperty::OPACITY); |
| - ExpectationSet usesMockAnimation; |
| - |
| - usesMockCurve += EXPECT_CALL(*m_mockCompositorFactory, createAnimation(Ref(*mockCurvePtr), CompositorTargetProperty::OPACITY, _, _)) |
| - .WillOnce(Return(mockAnimationPtr)); |
| - |
| - usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(1)); |
| - usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(0.0)); |
| - usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setDirection(CompositorAnimation::Direction::NORMAL)); |
| - usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setPlaybackRate(1)); |
| - |
| - EXPECT_CALL(*mockAnimationPtr, delete_()) |
| - .Times(1) |
| - .After(usesMockAnimation); |
| - EXPECT_CALL(*mockCurvePtr, delete_()) |
| - .Times(1) |
| - .After(usesMockCurve); |
| - |
| - // Go! |
| - Vector<OwnPtr<CompositorAnimation>> result; |
| - getAnimationOnCompositor(m_timing, *effect, result); |
| - EXPECT_EQ(1U, result.size()); |
| - result[0].reset(); |
| + std::unique_ptr<CcAnimationForTesting> animation = convertToCompositorAnimation(*effect); |
| + |
| + const CcKeyframedFloatAnimationCurveForTesting* keyframedFloatCurve = ToFloatCurve(animation.get()); |
| + DCHECK_EQ(2UL, keyframedFloatCurve->keyframes_for_testing().size()); |
| + |
| + auto curve_timing_function = ToCubicBezier(keyframedFloatCurve->timing_function_for_testing()); |
| + DCHECK(curve_timing_function); |
| + EXPECT_EQ(CubicBezierTimingFunction::EaseType::CUSTOM, curve_timing_function->ease_type()); |
| + |
| + const CcFloatKeyframeForTesting* keyframe1 = keyframedFloatCurve->keyframes_for_testing()[0].get(); |
| + EXPECT_EQ(TimeDeltaForTesting(), keyframe1->Time()); |
| + EXPECT_EQ(2.0f, keyframe1->Value()); |
| + EXPECT_FALSE(keyframe1->timing_function()); |
| + |
| + const CcFloatKeyframeForTesting* keyframe2 = keyframedFloatCurve->keyframes_for_testing()[1].get(); |
| + EXPECT_EQ(TimeDeltaForTesting::FromSecondsD(1.0), keyframe2->Time()); |
| + EXPECT_EQ(5.0f, keyframe2->Value()); |
| + const CcCubicBezierTimingFunctionForTesting* cubic2 = ToCubicBezier(keyframe2->timing_function()); |
| + EXPECT_EQ(CubicBezierTimingFunction::EaseType::EASE, cubic2->ease_type()); |
| } |
| -TEST_F(AnimationCompositorAnimationsTest, CancelIncompatibleCompositorAnimations) |
| +TEST_F(AnimationCompositorAnimationsTest, cancelIncompatibleCompositorAnimations) |
| { |
| Persistent<Element> element = m_document->createElement("shared", ASSERT_NO_EXCEPTION); |