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

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

Issue 196413030: Web animations: Supply CSS transition easing (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 6 years, 9 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
« no previous file with comments | « Source/core/animation/KeyframeEffectModel.cpp ('k') | Source/core/animation/css/CSSAnimations.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/animation/KeyframeEffectModelTest.cpp
diff --git a/Source/core/animation/KeyframeEffectModelTest.cpp b/Source/core/animation/KeyframeEffectModelTest.cpp
index 50eda1402e829ba489520de61c2fa838591b9f75..779da432757951a05b263d9b2ceef3d588729959 100644
--- a/Source/core/animation/KeyframeEffectModelTest.cpp
+++ b/Source/core/animation/KeyframeEffectModelTest.cpp
@@ -42,6 +42,8 @@ using namespace WebCore;
namespace {
+const double duration = 1.0;
+
PassRefPtrWillBeRawPtr<AnimatableValue> unknownAnimatableValue(double n)
{
return AnimatableUnknown::create(CSSPrimitiveValue::create(n, CSSPrimitiveValue::CSS_UNKNOWN).get());
@@ -101,7 +103,7 @@ TEST(AnimationKeyframeEffectModel, BasicOperation)
{
KeyframeEffectModel::KeyframeVector keyframes = keyframesAtZeroAndOne(unknownAnimatableValue(3.0), unknownAnimatableValue(5.0));
RefPtrWillBeRawPtr<KeyframeEffectModel> effect = KeyframeEffectModel::create(keyframes);
- OwnPtr<Vector<RefPtr<Interpolation> > > values = effect->sample(0, 0.6);
+ OwnPtr<Vector<RefPtr<Interpolation> > > values = effect->sample(0, 0.6, duration);
ASSERT_EQ(1UL, values->size());
expectProperty(CSSPropertyLeft, values->at(0));
expectDoubleValue(5.0, values->at(0));
@@ -113,7 +115,7 @@ TEST(AnimationKeyframeEffectModel, CompositeReplaceNonInterpolable)
keyframes[0]->setComposite(AnimationEffect::CompositeReplace);
keyframes[1]->setComposite(AnimationEffect::CompositeReplace);
RefPtrWillBeRawPtr<KeyframeEffectModel> effect = KeyframeEffectModel::create(keyframes);
- expectDoubleValue(5.0, effect->sample(0, 0.6)->at(0));
+ expectDoubleValue(5.0, effect->sample(0, 0.6, duration)->at(0));
}
TEST(AnimationKeyframeEffectModel, CompositeReplace)
@@ -122,7 +124,7 @@ TEST(AnimationKeyframeEffectModel, CompositeReplace)
keyframes[0]->setComposite(AnimationEffect::CompositeReplace);
keyframes[1]->setComposite(AnimationEffect::CompositeReplace);
RefPtrWillBeRawPtr<KeyframeEffectModel> effect = KeyframeEffectModel::create(keyframes);
- expectDoubleValue(3.0 * 0.4 + 5.0 * 0.6, effect->sample(0, 0.6)->at(0));
+ expectDoubleValue(3.0 * 0.4 + 5.0 * 0.6, effect->sample(0, 0.6, duration)->at(0));
}
// FIXME: Re-enable this test once compositing of CompositeAdd is supported.
@@ -132,7 +134,7 @@ TEST(AnimationKeyframeEffectModel, DISABLED_CompositeAdd)
keyframes[0]->setComposite(AnimationEffect::CompositeAdd);
keyframes[1]->setComposite(AnimationEffect::CompositeAdd);
RefPtrWillBeRawPtr<KeyframeEffectModel> effect = KeyframeEffectModel::create(keyframes);
- expectDoubleValue((7.0 + 3.0) * 0.4 + (7.0 + 5.0) * 0.6, effect->sample(0, 0.6)->at(0));
+ expectDoubleValue((7.0 + 3.0) * 0.4 + (7.0 + 5.0) * 0.6, effect->sample(0, 0.6, duration)->at(0));
}
TEST(AnimationKeyframeEffectModel, CompositeEaseIn)
@@ -143,7 +145,8 @@ TEST(AnimationKeyframeEffectModel, CompositeEaseIn)
keyframes[0]->setEasing(CSSToStyleMap::animationTimingFunction(timingFunction.get(), false));
keyframes[1]->setComposite(AnimationEffect::CompositeReplace);
RefPtrWillBeRawPtr<KeyframeEffectModel> effect = KeyframeEffectModel::create(keyframes);
- expectDoubleValue(3.8582394, effect->sample(0, 0.6)->at(0));
+ expectDoubleValue(3.8579516, effect->sample(0, 0.6, duration)->at(0));
+ expectDoubleValue(3.8582394, effect->sample(0, 0.6, duration * 100)->at(0));
}
TEST(AnimationKeyframeEffectModel, CompositeCubicBezier)
@@ -154,7 +157,8 @@ TEST(AnimationKeyframeEffectModel, CompositeCubicBezier)
keyframes[0]->setEasing(CSSToStyleMap::animationTimingFunction(timingFunction.get(), false));
keyframes[1]->setComposite(AnimationEffect::CompositeReplace);
RefPtrWillBeRawPtr<KeyframeEffectModel> effect = KeyframeEffectModel::create(keyframes);
- expectDoubleValue(4.3362322, effect->sample(0, 0.6)->at(0));
+ expectDoubleValue(4.3363357, effect->sample(0, 0.6, duration)->at(0));
+ expectDoubleValue(4.3362322, effect->sample(0, 0.6, duration * 1000)->at(0));
}
TEST(AnimationKeyframeEffectModel, ExtrapolateReplaceNonInterpolable)
@@ -163,7 +167,7 @@ TEST(AnimationKeyframeEffectModel, ExtrapolateReplaceNonInterpolable)
keyframes[0]->setComposite(AnimationEffect::CompositeReplace);
keyframes[1]->setComposite(AnimationEffect::CompositeReplace);
RefPtrWillBeRawPtr<KeyframeEffectModel> effect = KeyframeEffectModel::create(keyframes);
- expectDoubleValue(5.0, effect->sample(0, 1.6)->at(0));
+ expectDoubleValue(5.0, effect->sample(0, 1.6, duration)->at(0));
}
TEST(AnimationKeyframeEffectModel, ExtrapolateReplace)
@@ -172,7 +176,7 @@ TEST(AnimationKeyframeEffectModel, ExtrapolateReplace)
RefPtrWillBeRawPtr<KeyframeEffectModel> effect = KeyframeEffectModel::create(keyframes);
keyframes[0]->setComposite(AnimationEffect::CompositeReplace);
keyframes[1]->setComposite(AnimationEffect::CompositeReplace);
- expectDoubleValue(3.0 * -0.6 + 5.0 * 1.6, effect->sample(0, 1.6)->at(0));
+ expectDoubleValue(3.0 * -0.6 + 5.0 * 1.6, effect->sample(0, 1.6, duration)->at(0));
}
// FIXME: Re-enable this test once compositing of CompositeAdd is supported.
@@ -182,13 +186,13 @@ TEST(AnimationKeyframeEffectModel, DISABLED_ExtrapolateAdd)
keyframes[0]->setComposite(AnimationEffect::CompositeAdd);
keyframes[1]->setComposite(AnimationEffect::CompositeAdd);
RefPtrWillBeRawPtr<KeyframeEffectModel> effect = KeyframeEffectModel::create(keyframes);
- expectDoubleValue((7.0 + 3.0) * -0.6 + (7.0 + 5.0) * 1.6, effect->sample(0, 1.6)->at(0));
+ expectDoubleValue((7.0 + 3.0) * -0.6 + (7.0 + 5.0) * 1.6, effect->sample(0, 1.6, duration)->at(0));
}
TEST(AnimationKeyframeEffectModel, ZeroKeyframes)
{
RefPtrWillBeRawPtr<KeyframeEffectModel> effect = KeyframeEffectModel::create(KeyframeEffectModel::KeyframeVector());
- EXPECT_TRUE(effect->sample(0, 0.5)->isEmpty());
+ EXPECT_TRUE(effect->sample(0, 0.5, duration)->isEmpty());
}
// FIXME: Re-enable this test once compositing of CompositeAdd is supported.
@@ -200,7 +204,7 @@ TEST(AnimationKeyframeEffectModel, DISABLED_SingleKeyframeAtOffsetZero)
keyframes[0]->setPropertyValue(CSSPropertyLeft, unknownAnimatableValue(3.0).get());
RefPtrWillBeRawPtr<KeyframeEffectModel> effect = KeyframeEffectModel::create(keyframes);
- expectDoubleValue(3.0, effect->sample(0, 0.6)->at(0));
+ expectDoubleValue(3.0, effect->sample(0, 0.6, duration)->at(0));
}
// FIXME: Re-enable this test once compositing of CompositeAdd is supported.
@@ -212,7 +216,7 @@ TEST(AnimationKeyframeEffectModel, DISABLED_SingleKeyframeAtOffsetOne)
keyframes[0]->setPropertyValue(CSSPropertyLeft, pixelAnimatableValue(5.0).get());
RefPtrWillBeRawPtr<KeyframeEffectModel> effect = KeyframeEffectModel::create(keyframes);
- expectDoubleValue(7.0 * 0.4 + 5.0 * 0.6, effect->sample(0, 0.6)->at(0));
+ expectDoubleValue(7.0 * 0.4 + 5.0 * 0.6, effect->sample(0, 0.6, duration)->at(0));
}
TEST(AnimationKeyframeEffectModel, MoreThanTwoKeyframes)
@@ -229,8 +233,8 @@ TEST(AnimationKeyframeEffectModel, MoreThanTwoKeyframes)
keyframes[2]->setPropertyValue(CSSPropertyLeft, unknownAnimatableValue(5.0).get());
RefPtrWillBeRawPtr<KeyframeEffectModel> effect = KeyframeEffectModel::create(keyframes);
- expectDoubleValue(4.0, effect->sample(0, 0.3)->at(0));
- expectDoubleValue(5.0, effect->sample(0, 0.8)->at(0));
+ expectDoubleValue(4.0, effect->sample(0, 0.3, duration)->at(0));
+ expectDoubleValue(5.0, effect->sample(0, 0.8, duration)->at(0));
}
TEST(AnimationKeyframeEffectModel, EndKeyframeOffsetsUnspecified)
@@ -245,9 +249,9 @@ TEST(AnimationKeyframeEffectModel, EndKeyframeOffsetsUnspecified)
keyframes[2]->setPropertyValue(CSSPropertyLeft, unknownAnimatableValue(5.0).get());
RefPtrWillBeRawPtr<KeyframeEffectModel> effect = KeyframeEffectModel::create(keyframes);
- expectDoubleValue(3.0, effect->sample(0, 0.1)->at(0));
- expectDoubleValue(4.0, effect->sample(0, 0.6)->at(0));
- expectDoubleValue(5.0, effect->sample(0, 0.9)->at(0));
+ expectDoubleValue(3.0, effect->sample(0, 0.1, duration)->at(0));
+ expectDoubleValue(4.0, effect->sample(0, 0.6, duration)->at(0));
+ expectDoubleValue(5.0, effect->sample(0, 0.9, duration)->at(0));
}
TEST(AnimationKeyframeEffectModel, SampleOnKeyframe)
@@ -264,9 +268,9 @@ TEST(AnimationKeyframeEffectModel, SampleOnKeyframe)
keyframes[2]->setPropertyValue(CSSPropertyLeft, unknownAnimatableValue(5.0).get());
RefPtrWillBeRawPtr<KeyframeEffectModel> effect = KeyframeEffectModel::create(keyframes);
- expectDoubleValue(3.0, effect->sample(0, 0.0)->at(0));
- expectDoubleValue(4.0, effect->sample(0, 0.5)->at(0));
- expectDoubleValue(5.0, effect->sample(0, 1.0)->at(0));
+ expectDoubleValue(3.0, effect->sample(0, 0.0, duration)->at(0));
+ expectDoubleValue(4.0, effect->sample(0, 0.5, duration)->at(0));
+ expectDoubleValue(5.0, effect->sample(0, 1.0, duration)->at(0));
}
TEST(AnimationKeyframeEffectModel, MultipleKeyframesWithSameOffset)
@@ -301,13 +305,13 @@ TEST(AnimationKeyframeEffectModel, MultipleKeyframesWithSameOffset)
keyframes[8]->setPropertyValue(CSSPropertyLeft, unknownAnimatableValue(7.0).get());
RefPtrWillBeRawPtr<KeyframeEffectModel> effect = KeyframeEffectModel::create(keyframes);
- expectDoubleValue(0.0, effect->sample(0, 0.0)->at(0));
- expectDoubleValue(2.0, effect->sample(0, 0.2)->at(0));
- expectDoubleValue(3.0, effect->sample(0, 0.4)->at(0));
- expectDoubleValue(5.0, effect->sample(0, 0.5)->at(0));
- expectDoubleValue(5.0, effect->sample(0, 0.6)->at(0));
- expectDoubleValue(6.0, effect->sample(0, 0.8)->at(0));
- expectDoubleValue(7.0, effect->sample(0, 1.0)->at(0));
+ expectDoubleValue(0.0, effect->sample(0, 0.0, duration)->at(0));
+ expectDoubleValue(2.0, effect->sample(0, 0.2, duration)->at(0));
+ expectDoubleValue(3.0, effect->sample(0, 0.4, duration)->at(0));
+ expectDoubleValue(5.0, effect->sample(0, 0.5, duration)->at(0));
+ expectDoubleValue(5.0, effect->sample(0, 0.6, duration)->at(0));
+ expectDoubleValue(6.0, effect->sample(0, 0.8, duration)->at(0));
+ expectDoubleValue(7.0, effect->sample(0, 1.0, duration)->at(0));
}
// FIXME: Re-enable this test once compositing of CompositeAdd is supported.
@@ -323,7 +327,7 @@ TEST(AnimationKeyframeEffectModel, DISABLED_PerKeyframeComposite)
keyframes[1]->setComposite(AnimationEffect::CompositeAdd);
RefPtrWillBeRawPtr<KeyframeEffectModel> effect = KeyframeEffectModel::create(keyframes);
- expectDoubleValue(3.0 * 0.4 + (7.0 + 5.0) * 0.6, effect->sample(0, 0.6)->at(0));
+ expectDoubleValue(3.0 * 0.4 + (7.0 + 5.0) * 0.6, effect->sample(0, 0.6, duration)->at(0));
}
TEST(AnimationKeyframeEffectModel, MultipleProperties)
@@ -339,7 +343,7 @@ TEST(AnimationKeyframeEffectModel, MultipleProperties)
keyframes[1]->setPropertyValue(CSSPropertyRight, unknownAnimatableValue(6.0).get());
RefPtrWillBeRawPtr<KeyframeEffectModel> effect = KeyframeEffectModel::create(keyframes);
- OwnPtr<Vector<RefPtr<Interpolation> > > values = effect->sample(0, 0.6);
+ OwnPtr<Vector<RefPtr<Interpolation> > > values = effect->sample(0, 0.6, duration);
EXPECT_EQ(2UL, values->size());
Interpolation* leftValue = findValue(*values.get(), CSSPropertyLeft);
ASSERT_TRUE(leftValue);
@@ -356,7 +360,7 @@ TEST(AnimationKeyframeEffectModel, DISABLED_RecompositeCompositableValue)
keyframes[0]->setComposite(AnimationEffect::CompositeAdd);
keyframes[1]->setComposite(AnimationEffect::CompositeAdd);
RefPtrWillBeRawPtr<KeyframeEffectModel> effect = KeyframeEffectModel::create(keyframes);
- OwnPtr<Vector<RefPtr<Interpolation> > > values = effect->sample(0, 0.6);
+ OwnPtr<Vector<RefPtr<Interpolation> > > values = effect->sample(0, 0.6, duration);
expectDoubleValue((7.0 + 3.0) * 0.4 + (7.0 + 5.0) * 0.6, values->at(0));
expectDoubleValue((9.0 + 3.0) * 0.4 + (9.0 + 5.0) * 0.6, values->at(0));
}
@@ -365,9 +369,9 @@ TEST(AnimationKeyframeEffectModel, MultipleIterations)
{
KeyframeEffectModel::KeyframeVector keyframes = keyframesAtZeroAndOne(pixelAnimatableValue(1.0), pixelAnimatableValue(3.0));
RefPtrWillBeRawPtr<KeyframeEffectModel> effect = KeyframeEffectModel::create(keyframes);
- expectDoubleValue(2.0, effect->sample(0, 0.5)->at(0));
- expectDoubleValue(2.0, effect->sample(1, 0.5)->at(0));
- expectDoubleValue(2.0, effect->sample(2, 0.5)->at(0));
+ expectDoubleValue(2.0, effect->sample(0, 0.5, duration)->at(0));
+ expectDoubleValue(2.0, effect->sample(1, 0.5, duration)->at(0));
+ expectDoubleValue(2.0, effect->sample(2, 0.5, duration)->at(0));
}
// FIXME: Re-enable this test once compositing of CompositeAdd is supported.
@@ -386,15 +390,15 @@ TEST(AnimationKeyframeEffectModel, DISABLED_DependsOnUnderlyingValue)
keyframes[2]->setPropertyValue(CSSPropertyLeft, pixelAnimatableValue(1.0).get());
RefPtrWillBeRawPtr<KeyframeEffectModel> effect = KeyframeEffectModel::create(keyframes);
- EXPECT_TRUE(effect->sample(0, 0)->at(0));
- EXPECT_TRUE(effect->sample(0, 0.1)->at(0));
- EXPECT_TRUE(effect->sample(0, 0.25)->at(0));
- EXPECT_TRUE(effect->sample(0, 0.4)->at(0));
- EXPECT_FALSE(effect->sample(0, 0.5)->at(0));
- EXPECT_FALSE(effect->sample(0, 0.6)->at(0));
- EXPECT_FALSE(effect->sample(0, 0.75)->at(0));
- EXPECT_FALSE(effect->sample(0, 0.8)->at(0));
- EXPECT_FALSE(effect->sample(0, 1)->at(0));
+ EXPECT_TRUE(effect->sample(0, 0, duration)->at(0));
+ EXPECT_TRUE(effect->sample(0, 0.1, duration)->at(0));
+ EXPECT_TRUE(effect->sample(0, 0.25, duration)->at(0));
+ EXPECT_TRUE(effect->sample(0, 0.4, duration)->at(0));
+ EXPECT_FALSE(effect->sample(0, 0.5, duration)->at(0));
+ EXPECT_FALSE(effect->sample(0, 0.6, duration)->at(0));
+ EXPECT_FALSE(effect->sample(0, 0.75, duration)->at(0));
+ EXPECT_FALSE(effect->sample(0, 0.8, duration)->at(0));
+ EXPECT_FALSE(effect->sample(0, 1, duration)->at(0));
}
TEST(AnimationKeyframeEffectModel, AddSyntheticKeyframes)
« no previous file with comments | « Source/core/animation/KeyframeEffectModel.cpp ('k') | Source/core/animation/css/CSSAnimations.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698