OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 #include "core/animation/InterpolationEffect.h" | 6 #include "core/animation/InterpolationEffect.h" |
7 | 7 |
8 #include <gtest/gtest.h> | 8 #include <gtest/gtest.h> |
9 | 9 |
10 namespace { | 10 namespace { |
(...skipping 16 matching lines...) Expand all Loading... |
27 return toInterpolableNumber(interpolationValue(*value.get()))->value(); | 27 return toInterpolableNumber(interpolationValue(*value.get()))->value(); |
28 } | 28 } |
29 }; | 29 }; |
30 | 30 |
31 TEST_F(AnimationInterpolationEffectTest, SingleInterpolation) | 31 TEST_F(AnimationInterpolationEffectTest, SingleInterpolation) |
32 { | 32 { |
33 RefPtrWillBeRawPtr<InterpolationEffect> interpolationEffect = InterpolationE
ffect::create(); | 33 RefPtrWillBeRawPtr<InterpolationEffect> interpolationEffect = InterpolationE
ffect::create(); |
34 interpolationEffect->addInterpolation(Interpolation::create(InterpolableNumb
er::create(0), InterpolableNumber::create(10)), | 34 interpolationEffect->addInterpolation(Interpolation::create(InterpolableNumb
er::create(0), InterpolableNumber::create(10)), |
35 RefPtr<TimingFunction>(), 0, 1, -1, 2); | 35 RefPtr<TimingFunction>(), 0, 1, -1, 2); |
36 | 36 |
37 OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation> > > ac
tiveInterpolations = interpolationEffect->getActiveInterpolations(-2, duration); | 37 OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation> > > ac
tiveInterpolations = nullptr; |
| 38 interpolationEffect->getActiveInterpolations(-2, duration, activeInterpolati
ons); |
38 EXPECT_EQ(0ul, activeInterpolations->size()); | 39 EXPECT_EQ(0ul, activeInterpolations->size()); |
39 | 40 |
40 activeInterpolations = interpolationEffect->getActiveInterpolations(-0.5, du
ration); | 41 interpolationEffect->getActiveInterpolations(-0.5, duration, activeInterpola
tions); |
41 EXPECT_EQ(1ul, activeInterpolations->size()); | 42 EXPECT_EQ(1ul, activeInterpolations->size()); |
42 EXPECT_EQ(-5, getInterpolableNumber(activeInterpolations->at(0))); | 43 EXPECT_EQ(-5, getInterpolableNumber(activeInterpolations->at(0))); |
43 | 44 |
44 activeInterpolations = interpolationEffect->getActiveInterpolations(0.5, dur
ation); | 45 interpolationEffect->getActiveInterpolations(0.5, duration, activeInterpolat
ions); |
45 EXPECT_EQ(1ul, activeInterpolations->size()); | 46 EXPECT_EQ(1ul, activeInterpolations->size()); |
46 EXPECT_FLOAT_EQ(5, getInterpolableNumber(activeInterpolations->at(0))); | 47 EXPECT_FLOAT_EQ(5, getInterpolableNumber(activeInterpolations->at(0))); |
47 | 48 |
48 activeInterpolations = interpolationEffect->getActiveInterpolations(1.5, dur
ation); | 49 interpolationEffect->getActiveInterpolations(1.5, duration, activeInterpolat
ions); |
49 EXPECT_EQ(1ul, activeInterpolations->size()); | 50 EXPECT_EQ(1ul, activeInterpolations->size()); |
50 EXPECT_FLOAT_EQ(15, getInterpolableNumber(activeInterpolations->at(0))); | 51 EXPECT_FLOAT_EQ(15, getInterpolableNumber(activeInterpolations->at(0))); |
51 | 52 |
52 activeInterpolations = interpolationEffect->getActiveInterpolations(3, durat
ion); | 53 interpolationEffect->getActiveInterpolations(3, duration, activeInterpolatio
ns); |
53 EXPECT_EQ(0ul, activeInterpolations->size()); | 54 EXPECT_EQ(0ul, activeInterpolations->size()); |
54 } | 55 } |
55 | 56 |
56 TEST_F(AnimationInterpolationEffectTest, MultipleInterpolations) | 57 TEST_F(AnimationInterpolationEffectTest, MultipleInterpolations) |
57 { | 58 { |
58 RefPtrWillBeRawPtr<InterpolationEffect> interpolationEffect = InterpolationE
ffect::create(); | 59 RefPtrWillBeRawPtr<InterpolationEffect> interpolationEffect = InterpolationE
ffect::create(); |
59 interpolationEffect->addInterpolation(Interpolation::create(InterpolableNumb
er::create(10), InterpolableNumber::create(15)), | 60 interpolationEffect->addInterpolation(Interpolation::create(InterpolableNumb
er::create(10), InterpolableNumber::create(15)), |
60 RefPtr<TimingFunction>(), 1, 2, 1, 3); | 61 RefPtr<TimingFunction>(), 1, 2, 1, 3); |
61 interpolationEffect->addInterpolation(Interpolation::create(InterpolableNumb
er::create(0), InterpolableNumber::create(1)), | 62 interpolationEffect->addInterpolation(Interpolation::create(InterpolableNumb
er::create(0), InterpolableNumber::create(1)), |
62 LinearTimingFunction::shared(), 0, 1, 0, 1); | 63 LinearTimingFunction::shared(), 0, 1, 0, 1); |
63 interpolationEffect->addInterpolation(Interpolation::create(InterpolableNumb
er::create(1), InterpolableNumber::create(6)), | 64 interpolationEffect->addInterpolation(Interpolation::create(InterpolableNumb
er::create(1), InterpolableNumber::create(6)), |
64 CubicBezierTimingFunction::preset(CubicBezierTimingFunction::Ease), 0.5,
1.5, 0.5, 1.5); | 65 CubicBezierTimingFunction::preset(CubicBezierTimingFunction::Ease), 0.5,
1.5, 0.5, 1.5); |
65 | 66 |
66 OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation> > > ac
tiveInterpolations = interpolationEffect->getActiveInterpolations(-0.5, duration
); | 67 OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation> > > ac
tiveInterpolations = nullptr; |
| 68 interpolationEffect->getActiveInterpolations(-0.5, duration, activeInterpola
tions); |
67 EXPECT_EQ(0ul, activeInterpolations->size()); | 69 EXPECT_EQ(0ul, activeInterpolations->size()); |
68 | 70 |
69 activeInterpolations = interpolationEffect->getActiveInterpolations(0, durat
ion); | 71 interpolationEffect->getActiveInterpolations(0, duration, activeInterpolatio
ns); |
70 EXPECT_EQ(1ul, activeInterpolations->size()); | 72 EXPECT_EQ(1ul, activeInterpolations->size()); |
71 EXPECT_FLOAT_EQ(0, getInterpolableNumber(activeInterpolations->at(0))); | 73 EXPECT_FLOAT_EQ(0, getInterpolableNumber(activeInterpolations->at(0))); |
72 | 74 |
73 activeInterpolations = interpolationEffect->getActiveInterpolations(0.5, dur
ation); | 75 interpolationEffect->getActiveInterpolations(0.5, duration, activeInterpolat
ions); |
74 EXPECT_EQ(2ul, activeInterpolations->size()); | 76 EXPECT_EQ(2ul, activeInterpolations->size()); |
75 EXPECT_FLOAT_EQ(0.5f, getInterpolableNumber(activeInterpolations->at(0))); | 77 EXPECT_FLOAT_EQ(0.5f, getInterpolableNumber(activeInterpolations->at(0))); |
76 EXPECT_FLOAT_EQ(1, getInterpolableNumber(activeInterpolations->at(1))); | 78 EXPECT_FLOAT_EQ(1, getInterpolableNumber(activeInterpolations->at(1))); |
77 | 79 |
78 activeInterpolations = interpolationEffect->getActiveInterpolations(1, durat
ion); | 80 interpolationEffect->getActiveInterpolations(1, duration, activeInterpolatio
ns); |
79 EXPECT_EQ(2ul, activeInterpolations->size()); | 81 EXPECT_EQ(2ul, activeInterpolations->size()); |
80 EXPECT_FLOAT_EQ(10, getInterpolableNumber(activeInterpolations->at(0))); | 82 EXPECT_FLOAT_EQ(10, getInterpolableNumber(activeInterpolations->at(0))); |
81 EXPECT_FLOAT_EQ(5.0282884f, getInterpolableNumber(activeInterpolations->at(1
))); | 83 EXPECT_FLOAT_EQ(5.0282884f, getInterpolableNumber(activeInterpolations->at(1
))); |
82 | 84 |
83 activeInterpolations = interpolationEffect->getActiveInterpolations(1, durat
ion * 1000); | 85 interpolationEffect->getActiveInterpolations(1, duration * 1000, activeInter
polations); |
84 EXPECT_EQ(2ul, activeInterpolations->size()); | 86 EXPECT_EQ(2ul, activeInterpolations->size()); |
85 EXPECT_FLOAT_EQ(10, getInterpolableNumber(activeInterpolations->at(0))); | 87 EXPECT_FLOAT_EQ(10, getInterpolableNumber(activeInterpolations->at(0))); |
86 EXPECT_FLOAT_EQ(5.0120168f, getInterpolableNumber(activeInterpolations->at(1
))); | 88 EXPECT_FLOAT_EQ(5.0120168f, getInterpolableNumber(activeInterpolations->at(1
))); |
87 | 89 |
88 activeInterpolations = interpolationEffect->getActiveInterpolations(1.5, dur
ation); | 90 interpolationEffect->getActiveInterpolations(1.5, duration, activeInterpolat
ions); |
89 EXPECT_EQ(1ul, activeInterpolations->size()); | 91 EXPECT_EQ(1ul, activeInterpolations->size()); |
90 EXPECT_FLOAT_EQ(12.5f, getInterpolableNumber(activeInterpolations->at(0))); | 92 EXPECT_FLOAT_EQ(12.5f, getInterpolableNumber(activeInterpolations->at(0))); |
91 | 93 |
92 activeInterpolations = interpolationEffect->getActiveInterpolations(2, durat
ion); | 94 interpolationEffect->getActiveInterpolations(2, duration, activeInterpolatio
ns); |
93 EXPECT_EQ(1ul, activeInterpolations->size()); | 95 EXPECT_EQ(1ul, activeInterpolations->size()); |
94 EXPECT_FLOAT_EQ(15, getInterpolableNumber(activeInterpolations->at(0))); | 96 EXPECT_FLOAT_EQ(15, getInterpolableNumber(activeInterpolations->at(0))); |
95 } | 97 } |
96 | 98 |
97 } | 99 } |
98 | |
OLD | NEW |