| 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 = nullptr; | 37 OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation>>> acti
veInterpolations = nullptr; |
| 38 interpolationEffect->getActiveInterpolations(-2, duration, activeInterpolati
ons); | 38 interpolationEffect->getActiveInterpolations(-2, duration, activeInterpolati
ons); |
| 39 EXPECT_EQ(0ul, activeInterpolations->size()); | 39 EXPECT_EQ(0ul, activeInterpolations->size()); |
| 40 | 40 |
| 41 interpolationEffect->getActiveInterpolations(-0.5, duration, activeInterpola
tions); | 41 interpolationEffect->getActiveInterpolations(-0.5, duration, activeInterpola
tions); |
| 42 EXPECT_EQ(1ul, activeInterpolations->size()); | 42 EXPECT_EQ(1ul, activeInterpolations->size()); |
| 43 EXPECT_EQ(-5, getInterpolableNumber(activeInterpolations->at(0))); | 43 EXPECT_EQ(-5, getInterpolableNumber(activeInterpolations->at(0))); |
| 44 | 44 |
| 45 interpolationEffect->getActiveInterpolations(0.5, duration, activeInterpolat
ions); | 45 interpolationEffect->getActiveInterpolations(0.5, duration, activeInterpolat
ions); |
| 46 EXPECT_EQ(1ul, activeInterpolations->size()); | 46 EXPECT_EQ(1ul, activeInterpolations->size()); |
| 47 EXPECT_FLOAT_EQ(5, getInterpolableNumber(activeInterpolations->at(0))); | 47 EXPECT_FLOAT_EQ(5, getInterpolableNumber(activeInterpolations->at(0))); |
| 48 | 48 |
| 49 interpolationEffect->getActiveInterpolations(1.5, duration, activeInterpolat
ions); | 49 interpolationEffect->getActiveInterpolations(1.5, duration, activeInterpolat
ions); |
| 50 EXPECT_EQ(1ul, activeInterpolations->size()); | 50 EXPECT_EQ(1ul, activeInterpolations->size()); |
| 51 EXPECT_FLOAT_EQ(15, getInterpolableNumber(activeInterpolations->at(0))); | 51 EXPECT_FLOAT_EQ(15, getInterpolableNumber(activeInterpolations->at(0))); |
| 52 | 52 |
| 53 interpolationEffect->getActiveInterpolations(3, duration, activeInterpolatio
ns); | 53 interpolationEffect->getActiveInterpolations(3, duration, activeInterpolatio
ns); |
| 54 EXPECT_EQ(0ul, activeInterpolations->size()); | 54 EXPECT_EQ(0ul, activeInterpolations->size()); |
| 55 } | 55 } |
| 56 | 56 |
| 57 TEST_F(AnimationInterpolationEffectTest, MultipleInterpolations) | 57 TEST_F(AnimationInterpolationEffectTest, MultipleInterpolations) |
| 58 { | 58 { |
| 59 RefPtrWillBeRawPtr<InterpolationEffect> interpolationEffect = InterpolationE
ffect::create(); | 59 RefPtrWillBeRawPtr<InterpolationEffect> interpolationEffect = InterpolationE
ffect::create(); |
| 60 interpolationEffect->addInterpolation(Interpolation::create(InterpolableNumb
er::create(10), InterpolableNumber::create(15)), | 60 interpolationEffect->addInterpolation(Interpolation::create(InterpolableNumb
er::create(10), InterpolableNumber::create(15)), |
| 61 RefPtr<TimingFunction>(), 1, 2, 1, 3); | 61 RefPtr<TimingFunction>(), 1, 2, 1, 3); |
| 62 interpolationEffect->addInterpolation(Interpolation::create(InterpolableNumb
er::create(0), InterpolableNumber::create(1)), | 62 interpolationEffect->addInterpolation(Interpolation::create(InterpolableNumb
er::create(0), InterpolableNumber::create(1)), |
| 63 LinearTimingFunction::shared(), 0, 1, 0, 1); | 63 LinearTimingFunction::shared(), 0, 1, 0, 1); |
| 64 interpolationEffect->addInterpolation(Interpolation::create(InterpolableNumb
er::create(1), InterpolableNumber::create(6)), | 64 interpolationEffect->addInterpolation(Interpolation::create(InterpolableNumb
er::create(1), InterpolableNumber::create(6)), |
| 65 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); |
| 66 | 66 |
| 67 OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation> > > ac
tiveInterpolations = nullptr; | 67 OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation>>> acti
veInterpolations = nullptr; |
| 68 interpolationEffect->getActiveInterpolations(-0.5, duration, activeInterpola
tions); | 68 interpolationEffect->getActiveInterpolations(-0.5, duration, activeInterpola
tions); |
| 69 EXPECT_EQ(0ul, activeInterpolations->size()); | 69 EXPECT_EQ(0ul, activeInterpolations->size()); |
| 70 | 70 |
| 71 interpolationEffect->getActiveInterpolations(0, duration, activeInterpolatio
ns); | 71 interpolationEffect->getActiveInterpolations(0, duration, activeInterpolatio
ns); |
| 72 EXPECT_EQ(1ul, activeInterpolations->size()); | 72 EXPECT_EQ(1ul, activeInterpolations->size()); |
| 73 EXPECT_FLOAT_EQ(0, getInterpolableNumber(activeInterpolations->at(0))); | 73 EXPECT_FLOAT_EQ(0, getInterpolableNumber(activeInterpolations->at(0))); |
| 74 | 74 |
| 75 interpolationEffect->getActiveInterpolations(0.5, duration, activeInterpolat
ions); | 75 interpolationEffect->getActiveInterpolations(0.5, duration, activeInterpolat
ions); |
| 76 EXPECT_EQ(2ul, activeInterpolations->size()); | 76 EXPECT_EQ(2ul, activeInterpolations->size()); |
| 77 EXPECT_FLOAT_EQ(0.5f, getInterpolableNumber(activeInterpolations->at(0))); | 77 EXPECT_FLOAT_EQ(0.5f, getInterpolableNumber(activeInterpolations->at(0))); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 90 interpolationEffect->getActiveInterpolations(1.5, duration, activeInterpolat
ions); | 90 interpolationEffect->getActiveInterpolations(1.5, duration, activeInterpolat
ions); |
| 91 EXPECT_EQ(1ul, activeInterpolations->size()); | 91 EXPECT_EQ(1ul, activeInterpolations->size()); |
| 92 EXPECT_FLOAT_EQ(12.5f, getInterpolableNumber(activeInterpolations->at(0))); | 92 EXPECT_FLOAT_EQ(12.5f, getInterpolableNumber(activeInterpolations->at(0))); |
| 93 | 93 |
| 94 interpolationEffect->getActiveInterpolations(2, duration, activeInterpolatio
ns); | 94 interpolationEffect->getActiveInterpolations(2, duration, activeInterpolatio
ns); |
| 95 EXPECT_EQ(1ul, activeInterpolations->size()); | 95 EXPECT_EQ(1ul, activeInterpolations->size()); |
| 96 EXPECT_FLOAT_EQ(15, getInterpolableNumber(activeInterpolations->at(0))); | 96 EXPECT_FLOAT_EQ(15, getInterpolableNumber(activeInterpolations->at(0))); |
| 97 } | 97 } |
| 98 | 98 |
| 99 } | 99 } |
| OLD | NEW |