| Index: third_party/WebKit/Source/core/animation/InterpolationEffectTest.cpp
|
| diff --git a/third_party/WebKit/Source/core/animation/InterpolationEffectTest.cpp b/third_party/WebKit/Source/core/animation/InterpolationEffectTest.cpp
|
| index 1d59730e91d46db349755585fa32172e4a4a8dec..fc9d6b7bf751cb6682f751bca356bb6f3cfaf6de 100644
|
| --- a/third_party/WebKit/Source/core/animation/InterpolationEffectTest.cpp
|
| +++ b/third_party/WebKit/Source/core/animation/InterpolationEffectTest.cpp
|
| @@ -13,20 +13,32 @@ namespace {
|
|
|
| class SampleInterpolation : public Interpolation {
|
| public:
|
| - static PassRefPtr<Interpolation> create(std::unique_ptr<InterpolableValue> start, std::unique_ptr<InterpolableValue> end)
|
| + static PassRefPtr<Interpolation> create(double start, double end)
|
| {
|
| - return adoptRef(new SampleInterpolation(std::move(start), std::move(end)));
|
| + return adoptRef(new SampleInterpolation(start, end));
|
| }
|
|
|
| PropertyHandle getProperty() const override
|
| {
|
| return PropertyHandle(CSSPropertyBackgroundColor);
|
| }
|
| -private:
|
| - SampleInterpolation(std::unique_ptr<InterpolableValue> start, std::unique_ptr<InterpolableValue> end)
|
| - : Interpolation(std::move(start), std::move(end))
|
| +
|
| + const double start;
|
| + const double end;
|
| + double current;
|
| +
|
| +protected:
|
| + void interpolateImpl() final
|
| {
|
| + current = blend(start, end, m_currentFraction);
|
| }
|
| +
|
| +private:
|
| + SampleInterpolation(double start, double end)
|
| + : start(start)
|
| + , end(end)
|
| + , current(start)
|
| + { }
|
| };
|
|
|
| const double duration = 1.0;
|
| @@ -35,21 +47,16 @@ const double duration = 1.0;
|
|
|
| class AnimationInterpolationEffectTest : public ::testing::Test {
|
| protected:
|
| - InterpolableValue* interpolationValue(Interpolation& interpolation)
|
| - {
|
| - return interpolation.getCachedValueForTesting();
|
| - }
|
| -
|
| - double getInterpolableNumber(PassRefPtr<Interpolation> value)
|
| + double getNumber(PassRefPtr<Interpolation> value)
|
| {
|
| - return toInterpolableNumber(interpolationValue(*value.get()))->value();
|
| + return static_cast<SampleInterpolation&>(*value).current;
|
| }
|
| };
|
|
|
| TEST_F(AnimationInterpolationEffectTest, SingleInterpolation)
|
| {
|
| InterpolationEffect interpolationEffect;
|
| - interpolationEffect.addInterpolation(SampleInterpolation::create(InterpolableNumber::create(0), InterpolableNumber::create(10)),
|
| + interpolationEffect.addInterpolation(SampleInterpolation::create(0, 10),
|
| RefPtr<TimingFunction>(), 0, 1, -1, 2);
|
|
|
| Vector<RefPtr<Interpolation>> activeInterpolations;
|
| @@ -58,15 +65,15 @@ TEST_F(AnimationInterpolationEffectTest, SingleInterpolation)
|
|
|
| interpolationEffect.getActiveInterpolations(-0.5, duration, activeInterpolations);
|
| EXPECT_EQ(1ul, activeInterpolations.size());
|
| - EXPECT_EQ(-5, getInterpolableNumber(activeInterpolations.at(0)));
|
| + EXPECT_EQ(-5, getNumber(activeInterpolations.at(0)));
|
|
|
| interpolationEffect.getActiveInterpolations(0.5, duration, activeInterpolations);
|
| EXPECT_EQ(1ul, activeInterpolations.size());
|
| - EXPECT_FLOAT_EQ(5, getInterpolableNumber(activeInterpolations.at(0)));
|
| + EXPECT_FLOAT_EQ(5, getNumber(activeInterpolations.at(0)));
|
|
|
| interpolationEffect.getActiveInterpolations(1.5, duration, activeInterpolations);
|
| EXPECT_EQ(1ul, activeInterpolations.size());
|
| - EXPECT_FLOAT_EQ(15, getInterpolableNumber(activeInterpolations.at(0)));
|
| + EXPECT_FLOAT_EQ(15, getNumber(activeInterpolations.at(0)));
|
|
|
| interpolationEffect.getActiveInterpolations(3, duration, activeInterpolations);
|
| EXPECT_EQ(0ul, activeInterpolations.size());
|
| @@ -75,11 +82,11 @@ TEST_F(AnimationInterpolationEffectTest, SingleInterpolation)
|
| TEST_F(AnimationInterpolationEffectTest, MultipleInterpolations)
|
| {
|
| InterpolationEffect interpolationEffect;
|
| - interpolationEffect.addInterpolation(SampleInterpolation::create(InterpolableNumber::create(10), InterpolableNumber::create(15)),
|
| + interpolationEffect.addInterpolation(SampleInterpolation::create(10, 15),
|
| RefPtr<TimingFunction>(), 1, 2, 1, 3);
|
| - interpolationEffect.addInterpolation(SampleInterpolation::create(InterpolableNumber::create(0), InterpolableNumber::create(1)),
|
| + interpolationEffect.addInterpolation(SampleInterpolation::create(0, 1),
|
| LinearTimingFunction::shared(), 0, 1, 0, 1);
|
| - interpolationEffect.addInterpolation(SampleInterpolation::create(InterpolableNumber::create(1), InterpolableNumber::create(6)),
|
| + interpolationEffect.addInterpolation(SampleInterpolation::create(1, 6),
|
| CubicBezierTimingFunction::preset(CubicBezierTimingFunction::EaseType::EASE), 0.5, 1.5, 0.5, 1.5);
|
|
|
| Vector<RefPtr<Interpolation>> activeInterpolations;
|
| @@ -88,30 +95,30 @@ TEST_F(AnimationInterpolationEffectTest, MultipleInterpolations)
|
|
|
| interpolationEffect.getActiveInterpolations(0, duration, activeInterpolations);
|
| EXPECT_EQ(1ul, activeInterpolations.size());
|
| - EXPECT_FLOAT_EQ(0, getInterpolableNumber(activeInterpolations.at(0)));
|
| + EXPECT_FLOAT_EQ(0, getNumber(activeInterpolations.at(0)));
|
|
|
| interpolationEffect.getActiveInterpolations(0.5, duration, activeInterpolations);
|
| EXPECT_EQ(2ul, activeInterpolations.size());
|
| - EXPECT_FLOAT_EQ(0.5f, getInterpolableNumber(activeInterpolations.at(0)));
|
| - EXPECT_FLOAT_EQ(1, getInterpolableNumber(activeInterpolations.at(1)));
|
| + EXPECT_FLOAT_EQ(0.5f, getNumber(activeInterpolations.at(0)));
|
| + EXPECT_FLOAT_EQ(1, getNumber(activeInterpolations.at(1)));
|
|
|
| interpolationEffect.getActiveInterpolations(1, duration, activeInterpolations);
|
| EXPECT_EQ(2ul, activeInterpolations.size());
|
| - EXPECT_FLOAT_EQ(10, getInterpolableNumber(activeInterpolations.at(0)));
|
| - EXPECT_FLOAT_EQ(5.0282884f, getInterpolableNumber(activeInterpolations.at(1)));
|
| + EXPECT_FLOAT_EQ(10, getNumber(activeInterpolations.at(0)));
|
| + EXPECT_FLOAT_EQ(5.0282884f, getNumber(activeInterpolations.at(1)));
|
|
|
| interpolationEffect.getActiveInterpolations(1, duration * 1000, activeInterpolations);
|
| EXPECT_EQ(2ul, activeInterpolations.size());
|
| - EXPECT_FLOAT_EQ(10, getInterpolableNumber(activeInterpolations.at(0)));
|
| - EXPECT_FLOAT_EQ(5.0120168f, getInterpolableNumber(activeInterpolations.at(1)));
|
| + EXPECT_FLOAT_EQ(10, getNumber(activeInterpolations.at(0)));
|
| + EXPECT_FLOAT_EQ(5.0120168f, getNumber(activeInterpolations.at(1)));
|
|
|
| interpolationEffect.getActiveInterpolations(1.5, duration, activeInterpolations);
|
| EXPECT_EQ(1ul, activeInterpolations.size());
|
| - EXPECT_FLOAT_EQ(12.5f, getInterpolableNumber(activeInterpolations.at(0)));
|
| + EXPECT_FLOAT_EQ(12.5f, getNumber(activeInterpolations.at(0)));
|
|
|
| interpolationEffect.getActiveInterpolations(2, duration, activeInterpolations);
|
| EXPECT_EQ(1ul, activeInterpolations.size());
|
| - EXPECT_FLOAT_EQ(15, getInterpolableNumber(activeInterpolations.at(0)));
|
| + EXPECT_FLOAT_EQ(15, getNumber(activeInterpolations.at(0)));
|
| }
|
|
|
| } // namespace blink
|
|
|