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

Unified Diff: Source/core/animation/CompositorAnimationsTest.cpp

Issue 800133004: Animation: Allow CC per-curve timing functions to be steps timing functions (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@0
Patch Set: Rebase Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: Source/core/animation/CompositorAnimationsTest.cpp
diff --git a/Source/core/animation/CompositorAnimationsTest.cpp b/Source/core/animation/CompositorAnimationsTest.cpp
index e3709360806702a6eaabf5e5c63ac383ecfebb28..850fdab36d1a0320e2cb833e9465cdf318194c12 100644
--- a/Source/core/animation/CompositorAnimationsTest.cpp
+++ b/Source/core/animation/CompositorAnimationsTest.cpp
@@ -466,18 +466,18 @@ TEST_F(AnimationCompositorAnimationsTest, isCandidateForAnimationOnCompositorTim
{
m_timing.timingFunction = m_cubicEaseTimingFunction;
EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, *m_keyframeAnimationEffect2.get()));
- EXPECT_FALSE(isCandidateForAnimationOnCompositor(m_timing, *m_keyframeAnimationEffect5.get()));
+ EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, *m_keyframeAnimationEffect5.get()));
m_timing.timingFunction = m_cubicCustomTimingFunction;
EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, *m_keyframeAnimationEffect2.get()));
- EXPECT_FALSE(isCandidateForAnimationOnCompositor(m_timing, *m_keyframeAnimationEffect5.get()));
+ EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, *m_keyframeAnimationEffect5.get()));
}
TEST_F(AnimationCompositorAnimationsTest, isCandidateForAnimationOnCompositorTimingFunctionSteps)
{
m_timing.timingFunction = m_stepTimingFunction;
EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, *m_keyframeAnimationEffect2.get()));
- EXPECT_FALSE(isCandidateForAnimationOnCompositor(m_timing, *m_keyframeAnimationEffect5.get()));
+ EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, *m_keyframeAnimationEffect5.get()));
}
TEST_F(AnimationCompositorAnimationsTest, isCandidateForAnimationOnCompositorTimingFunctionChainedLinear)
@@ -486,15 +486,21 @@ TEST_F(AnimationCompositorAnimationsTest, isCandidateForAnimationOnCompositorTim
EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, *m_keyframeAnimationEffect5.get()));
}
-TEST_F(AnimationCompositorAnimationsTest, isCandidateForAnimationOnCompositorNonLinearTimingFunctionOnFirstFrame)
+TEST_F(AnimationCompositorAnimationsTest, isCandidateForAnimationOnCompositorNonLinearTimingFunctionOnFirstOrLastFrame)
{
- m_timing.timingFunction = m_cubicEaseTimingFunction;
+ (*m_keyframeVector2)[0]->setEasing(m_cubicEaseTimingFunction.get());
+ m_keyframeAnimationEffect2 = AnimatableValueKeyframeEffectModel::create(*m_keyframeVector2);
+
+ (*m_keyframeVector5)[3]->setEasing(m_cubicEaseTimingFunction.get());
+ m_keyframeAnimationEffect5 = AnimatableValueKeyframeEffectModel::create(*m_keyframeVector5);
+ m_timing.timingFunction = m_cubicEaseTimingFunction;
EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, *m_keyframeAnimationEffect2.get()));
+ EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, *m_keyframeAnimationEffect5.get()));
- (*m_keyframeVector2)[0]->setEasing(m_cubicEaseTimingFunction.get());
- m_keyframeAnimationEffect2 = AnimatableValueKeyframeEffectModel::create(*m_keyframeVector2);
+ m_timing.timingFunction = m_cubicCustomTimingFunction;
EXPECT_FALSE(isCandidateForAnimationOnCompositor(m_timing, *m_keyframeAnimationEffect2.get()));
+ EXPECT_FALSE(isCandidateForAnimationOnCompositor(m_timing, *m_keyframeAnimationEffect5.get()));
}
TEST_F(AnimationCompositorAnimationsTest, isCandidateForAnimationOnCompositorTimingFunctionChainedCubicMatchingOffsets)
@@ -1099,4 +1105,52 @@ TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationFillModeAu
result[0].clear();
}
+TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationWithTimingFunction)
+{
+ // Animation to convert
+ RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = createKeyframeEffectModel(
+ createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0).get(), 0),
+ createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0).get(), 1.0));
+
+ m_timing.timingFunction = m_cubicCustomTimingFunction;
+
+ WebCompositorSupportMock mockCompositor;
+
+ // Curve is created
+ WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock;
+ ExpectationSet usesMockCurve;
+ EXPECT_CALL(mockCompositor, createFloatAnimationCurve())
+ .WillOnce(Return(mockCurvePtr));
+
+ usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(0.0, 2.0), WebCompositorAnimationCurve::TimingFunctionTypeLinear));
+ usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(1.0, 5.0)));
+ usesMockCurve += EXPECT_CALL(*mockCurvePtr, setCubicBezierTimingFunction(1, 2, 3, 4));
+
+ // Create animation
+ WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMock(WebCompositorAnimation::TargetPropertyOpacity);
+ ExpectationSet usesMockAnimation;
+
+ usesMockCurve += EXPECT_CALL(mockCompositor, createAnimation(Ref(*mockCurvePtr), WebCompositorAnimation::TargetPropertyOpacity, _, _))
+ .WillOnce(Return(mockAnimationPtr));
+
+ usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(1));
+ usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(0.0));
+ usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setDirection(blink::WebCompositorAnimation::DirectionNormal));
+ usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setPlaybackRate(1));
+
+ EXPECT_CALL(*mockAnimationPtr, delete_())
+ .Times(1)
+ .After(usesMockAnimation);
+ EXPECT_CALL(*mockCurvePtr, delete_())
+ .Times(1)
+ .After(usesMockCurve);
+
+ // Go!
+ setCompositorForTesting(mockCompositor);
+ Vector<OwnPtr<WebCompositorAnimation> > result;
+ getAnimationOnCompositor(m_timing, *effect.get(), result);
+ EXPECT_EQ(1U, result.size());
+ result[0].clear();
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698