Chromium Code Reviews| Index: cc/animation/keyframed_animation_curve_unittest.cc |
| diff --git a/cc/animation/keyframed_animation_curve_unittest.cc b/cc/animation/keyframed_animation_curve_unittest.cc |
| index a7b0e345b99c95d9b84974d60dd18de6e7c310b0..8bc87d4d1fa10c69b1d75adb87c2e637daf44c13 100644 |
| --- a/cc/animation/keyframed_animation_curve_unittest.cc |
| +++ b/cc/animation/keyframed_animation_curve_unittest.cc |
| @@ -535,6 +535,31 @@ TEST(KeyframedAnimationCurveTest, StepsTimingFunctionStepAtEnd) { |
| } |
| } |
| +// Tests a frames timing function. |
| +TEST(KeyframedAnimationCurveTest, FramesTimingFunction) { |
| + std::unique_ptr<KeyframedFloatAnimationCurve> curve( |
| + KeyframedFloatAnimationCurve::Create()); |
| + curve->AddKeyframe(FloatKeyframe::Create(base::TimeDelta(), 0.f, |
| + FramesTimingFunction::Create(5))); |
| + curve->AddKeyframe( |
| + FloatKeyframe::Create(base::TimeDelta::FromSecondsD(1.0), 1.f, nullptr)); |
| + |
| + EXPECT_FLOAT_EQ(0.f, curve->GetValue(base::TimeDelta())); |
| + EXPECT_FLOAT_EQ(0.f, curve->GetValue(base::TimeDelta::FromSecondsD(0.1999))); |
| + EXPECT_FLOAT_EQ(0.25f, |
| + curve->GetValue(base::TimeDelta::FromSecondsD(0.2001))); |
| + EXPECT_FLOAT_EQ(0.25f, |
| + curve->GetValue(base::TimeDelta::FromSecondsD(0.3999))); |
| + EXPECT_FLOAT_EQ(0.5f, curve->GetValue(base::TimeDelta::FromSecondsD(0.4001))); |
| + EXPECT_FLOAT_EQ(0.5f, curve->GetValue(base::TimeDelta::FromSecondsD(0.5999))); |
| + EXPECT_FLOAT_EQ(0.75f, |
| + curve->GetValue(base::TimeDelta::FromSecondsD(0.6001))); |
| + EXPECT_FLOAT_EQ(0.75f, |
| + curve->GetValue(base::TimeDelta::FromSecondsD(0.7999))); |
| + EXPECT_FLOAT_EQ(1.f, curve->GetValue(base::TimeDelta::FromSecondsD(0.8001))); |
| + EXPECT_FLOAT_EQ(1.f, curve->GetValue(base::TimeDelta::FromSecondsD(1.0))); |
|
alancutter (OOO until 2018)
2017/03/29 04:58:30
These line wraps make the test a bit harder to rea
suzyh_UTC10 (ex-contributor)
2017/04/04 01:02:02
Rearranged. How's this?
git cl format has Opinion
|
| +} |
| + |
| // Tests that animated bounds are computed as expected. |
| TEST(KeyframedAnimationCurveTest, AnimatedBounds) { |
| std::unique_ptr<KeyframedTransformAnimationCurve> curve( |
| @@ -835,6 +860,23 @@ TEST(KeyframedAnimationCurveTest, StepsTimingInputsOutsideZeroOneRange) { |
| EXPECT_FLOAT_EQ(2.f, curve->GetValue(base::TimeDelta::FromSecondsD(0.75f))); |
| } |
| +// Tests that a frames timing function works as expected for inputs outside of |
| +// range [0,1] |
|
alancutter (OOO until 2018)
2017/03/29 04:58:30
Bah these comments, they're just repeating the tes
suzyh_UTC10 (ex-contributor)
2017/04/04 01:02:02
Ack.
|
| +TEST(KeyframedAnimationCurveTest, FramesTimingInputsOutsideZeroOneRange) { |
| + std::unique_ptr<KeyframedFloatAnimationCurve> curve( |
| + KeyframedFloatAnimationCurve::Create()); |
| + curve->AddKeyframe(FloatKeyframe::Create(base::TimeDelta(), 0.f, |
| + FramesTimingFunction::Create(5))); |
| + curve->AddKeyframe( |
| + FloatKeyframe::Create(base::TimeDelta::FromSecondsD(1.0), 2.f, nullptr)); |
| + // Curve timing function producing timing outputs outside of range [0,1]. |
| + curve->SetTimingFunction( |
| + CubicBezierTimingFunction::Create(0.5f, -0.5f, 0.5f, 1.5f)); |
| + |
| + EXPECT_FLOAT_EQ(0.f, curve->GetValue(base::TimeDelta::FromSecondsD(0.25f))); |
| + EXPECT_FLOAT_EQ(2.f, curve->GetValue(base::TimeDelta::FromSecondsD(0.75f))); |
| +} |
| + |
| // Tests that an animation with a curve timing function and multiple keyframes |
| // works as expected. |
| TEST(KeyframedAnimationCurveTest, CurveTimingMultipleKeyframes) { |