Rename rendering/RenderFileUploadControl to layout/LayoutFileUploadControl.
[chromium-blink-merge.git] / third_party / WebKit / Source / core / animation / InterpolationEffectTest.cpp
blobe13ef629e6662f5d751a7489e9800b6e3e6f24d9
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "config.h"
6 #include "core/animation/InterpolationEffect.h"
8 #include <gtest/gtest.h>
10 namespace {
12 const double duration = 1.0;
14 } // namespace
16 namespace blink {
18 class AnimationInterpolationEffectTest : public ::testing::Test {
19 protected:
20 InterpolableValue* interpolationValue(Interpolation& interpolation)
22 return interpolation.getCachedValueForTesting();
25 double getInterpolableNumber(PassRefPtrWillBeRawPtr<Interpolation> value)
27 return toInterpolableNumber(interpolationValue(*value.get()))->value();
31 TEST_F(AnimationInterpolationEffectTest, SingleInterpolation)
33 RefPtrWillBeRawPtr<InterpolationEffect> interpolationEffect = InterpolationEffect::create();
34 interpolationEffect->addInterpolation(Interpolation::create(InterpolableNumber::create(0), InterpolableNumber::create(10)),
35 RefPtr<TimingFunction>(), 0, 1, -1, 2);
37 OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation> > > activeInterpolations = nullptr;
38 interpolationEffect->getActiveInterpolations(-2, duration, activeInterpolations);
39 EXPECT_EQ(0ul, activeInterpolations->size());
41 interpolationEffect->getActiveInterpolations(-0.5, duration, activeInterpolations);
42 EXPECT_EQ(1ul, activeInterpolations->size());
43 EXPECT_EQ(-5, getInterpolableNumber(activeInterpolations->at(0)));
45 interpolationEffect->getActiveInterpolations(0.5, duration, activeInterpolations);
46 EXPECT_EQ(1ul, activeInterpolations->size());
47 EXPECT_FLOAT_EQ(5, getInterpolableNumber(activeInterpolations->at(0)));
49 interpolationEffect->getActiveInterpolations(1.5, duration, activeInterpolations);
50 EXPECT_EQ(1ul, activeInterpolations->size());
51 EXPECT_FLOAT_EQ(15, getInterpolableNumber(activeInterpolations->at(0)));
53 interpolationEffect->getActiveInterpolations(3, duration, activeInterpolations);
54 EXPECT_EQ(0ul, activeInterpolations->size());
57 TEST_F(AnimationInterpolationEffectTest, MultipleInterpolations)
59 RefPtrWillBeRawPtr<InterpolationEffect> interpolationEffect = InterpolationEffect::create();
60 interpolationEffect->addInterpolation(Interpolation::create(InterpolableNumber::create(10), InterpolableNumber::create(15)),
61 RefPtr<TimingFunction>(), 1, 2, 1, 3);
62 interpolationEffect->addInterpolation(Interpolation::create(InterpolableNumber::create(0), InterpolableNumber::create(1)),
63 LinearTimingFunction::shared(), 0, 1, 0, 1);
64 interpolationEffect->addInterpolation(Interpolation::create(InterpolableNumber::create(1), InterpolableNumber::create(6)),
65 CubicBezierTimingFunction::preset(CubicBezierTimingFunction::Ease), 0.5, 1.5, 0.5, 1.5);
67 OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation> > > activeInterpolations = nullptr;
68 interpolationEffect->getActiveInterpolations(-0.5, duration, activeInterpolations);
69 EXPECT_EQ(0ul, activeInterpolations->size());
71 interpolationEffect->getActiveInterpolations(0, duration, activeInterpolations);
72 EXPECT_EQ(1ul, activeInterpolations->size());
73 EXPECT_FLOAT_EQ(0, getInterpolableNumber(activeInterpolations->at(0)));
75 interpolationEffect->getActiveInterpolations(0.5, duration, activeInterpolations);
76 EXPECT_EQ(2ul, activeInterpolations->size());
77 EXPECT_FLOAT_EQ(0.5f, getInterpolableNumber(activeInterpolations->at(0)));
78 EXPECT_FLOAT_EQ(1, getInterpolableNumber(activeInterpolations->at(1)));
80 interpolationEffect->getActiveInterpolations(1, duration, activeInterpolations);
81 EXPECT_EQ(2ul, activeInterpolations->size());
82 EXPECT_FLOAT_EQ(10, getInterpolableNumber(activeInterpolations->at(0)));
83 EXPECT_FLOAT_EQ(5.0282884f, getInterpolableNumber(activeInterpolations->at(1)));
85 interpolationEffect->getActiveInterpolations(1, duration * 1000, activeInterpolations);
86 EXPECT_EQ(2ul, activeInterpolations->size());
87 EXPECT_FLOAT_EQ(10, getInterpolableNumber(activeInterpolations->at(0)));
88 EXPECT_FLOAT_EQ(5.0120168f, getInterpolableNumber(activeInterpolations->at(1)));
90 interpolationEffect->getActiveInterpolations(1.5, duration, activeInterpolations);
91 EXPECT_EQ(1ul, activeInterpolations->size());
92 EXPECT_FLOAT_EQ(12.5f, getInterpolableNumber(activeInterpolations->at(0)));
94 interpolationEffect->getActiveInterpolations(2, duration, activeInterpolations);
95 EXPECT_EQ(1ul, activeInterpolations->size());
96 EXPECT_FLOAT_EQ(15, getInterpolableNumber(activeInterpolations->at(0)));