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 blink { | 10 namespace blink { |
(...skipping 30 matching lines...) Expand all Loading... |
41 } | 41 } |
42 | 42 |
43 double getInterpolableNumber(PassRefPtrWillBeRawPtr<Interpolation> value) | 43 double getInterpolableNumber(PassRefPtrWillBeRawPtr<Interpolation> value) |
44 { | 44 { |
45 return toInterpolableNumber(interpolationValue(*value.get()))->value(); | 45 return toInterpolableNumber(interpolationValue(*value.get()))->value(); |
46 } | 46 } |
47 }; | 47 }; |
48 | 48 |
49 TEST_F(AnimationInterpolationEffectTest, SingleInterpolation) | 49 TEST_F(AnimationInterpolationEffectTest, SingleInterpolation) |
50 { | 50 { |
51 RefPtrWillBeRawPtr<InterpolationEffect> interpolationEffect = InterpolationE
ffect::create(); | 51 InterpolationEffect* interpolationEffect = InterpolationEffect::create(); |
52 interpolationEffect->addInterpolation(SampleInterpolation::create(Interpolab
leNumber::create(0), InterpolableNumber::create(10)), | 52 interpolationEffect->addInterpolation(SampleInterpolation::create(Interpolab
leNumber::create(0), InterpolableNumber::create(10)), |
53 RefPtr<TimingFunction>(), 0, 1, -1, 2); | 53 RefPtr<TimingFunction>(), 0, 1, -1, 2); |
54 | 54 |
55 OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation>>> acti
veInterpolations = nullptr; | 55 OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation>>> acti
veInterpolations = nullptr; |
56 interpolationEffect->getActiveInterpolations(-2, duration, activeInterpolati
ons); | 56 interpolationEffect->getActiveInterpolations(-2, duration, activeInterpolati
ons); |
57 EXPECT_EQ(0ul, activeInterpolations->size()); | 57 EXPECT_EQ(0ul, activeInterpolations->size()); |
58 | 58 |
59 interpolationEffect->getActiveInterpolations(-0.5, duration, activeInterpola
tions); | 59 interpolationEffect->getActiveInterpolations(-0.5, duration, activeInterpola
tions); |
60 EXPECT_EQ(1ul, activeInterpolations->size()); | 60 EXPECT_EQ(1ul, activeInterpolations->size()); |
61 EXPECT_EQ(-5, getInterpolableNumber(activeInterpolations->at(0))); | 61 EXPECT_EQ(-5, getInterpolableNumber(activeInterpolations->at(0))); |
62 | 62 |
63 interpolationEffect->getActiveInterpolations(0.5, duration, activeInterpolat
ions); | 63 interpolationEffect->getActiveInterpolations(0.5, duration, activeInterpolat
ions); |
64 EXPECT_EQ(1ul, activeInterpolations->size()); | 64 EXPECT_EQ(1ul, activeInterpolations->size()); |
65 EXPECT_FLOAT_EQ(5, getInterpolableNumber(activeInterpolations->at(0))); | 65 EXPECT_FLOAT_EQ(5, getInterpolableNumber(activeInterpolations->at(0))); |
66 | 66 |
67 interpolationEffect->getActiveInterpolations(1.5, duration, activeInterpolat
ions); | 67 interpolationEffect->getActiveInterpolations(1.5, duration, activeInterpolat
ions); |
68 EXPECT_EQ(1ul, activeInterpolations->size()); | 68 EXPECT_EQ(1ul, activeInterpolations->size()); |
69 EXPECT_FLOAT_EQ(15, getInterpolableNumber(activeInterpolations->at(0))); | 69 EXPECT_FLOAT_EQ(15, getInterpolableNumber(activeInterpolations->at(0))); |
70 | 70 |
71 interpolationEffect->getActiveInterpolations(3, duration, activeInterpolatio
ns); | 71 interpolationEffect->getActiveInterpolations(3, duration, activeInterpolatio
ns); |
72 EXPECT_EQ(0ul, activeInterpolations->size()); | 72 EXPECT_EQ(0ul, activeInterpolations->size()); |
73 } | 73 } |
74 | 74 |
75 TEST_F(AnimationInterpolationEffectTest, MultipleInterpolations) | 75 TEST_F(AnimationInterpolationEffectTest, MultipleInterpolations) |
76 { | 76 { |
77 RefPtrWillBeRawPtr<InterpolationEffect> interpolationEffect = InterpolationE
ffect::create(); | 77 InterpolationEffect* interpolationEffect = InterpolationEffect::create(); |
78 interpolationEffect->addInterpolation(SampleInterpolation::create(Interpolab
leNumber::create(10), InterpolableNumber::create(15)), | 78 interpolationEffect->addInterpolation(SampleInterpolation::create(Interpolab
leNumber::create(10), InterpolableNumber::create(15)), |
79 RefPtr<TimingFunction>(), 1, 2, 1, 3); | 79 RefPtr<TimingFunction>(), 1, 2, 1, 3); |
80 interpolationEffect->addInterpolation(SampleInterpolation::create(Interpolab
leNumber::create(0), InterpolableNumber::create(1)), | 80 interpolationEffect->addInterpolation(SampleInterpolation::create(Interpolab
leNumber::create(0), InterpolableNumber::create(1)), |
81 LinearTimingFunction::shared(), 0, 1, 0, 1); | 81 LinearTimingFunction::shared(), 0, 1, 0, 1); |
82 interpolationEffect->addInterpolation(SampleInterpolation::create(Interpolab
leNumber::create(1), InterpolableNumber::create(6)), | 82 interpolationEffect->addInterpolation(SampleInterpolation::create(Interpolab
leNumber::create(1), InterpolableNumber::create(6)), |
83 CubicBezierTimingFunction::preset(CubicBezierTimingFunction::Ease), 0.5,
1.5, 0.5, 1.5); | 83 CubicBezierTimingFunction::preset(CubicBezierTimingFunction::Ease), 0.5,
1.5, 0.5, 1.5); |
84 | 84 |
85 OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation>>> acti
veInterpolations = nullptr; | 85 OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation>>> acti
veInterpolations = nullptr; |
86 interpolationEffect->getActiveInterpolations(-0.5, duration, activeInterpola
tions); | 86 interpolationEffect->getActiveInterpolations(-0.5, duration, activeInterpola
tions); |
87 EXPECT_EQ(0ul, activeInterpolations->size()); | 87 EXPECT_EQ(0ul, activeInterpolations->size()); |
(...skipping 20 matching lines...) Expand all Loading... |
108 interpolationEffect->getActiveInterpolations(1.5, duration, activeInterpolat
ions); | 108 interpolationEffect->getActiveInterpolations(1.5, duration, activeInterpolat
ions); |
109 EXPECT_EQ(1ul, activeInterpolations->size()); | 109 EXPECT_EQ(1ul, activeInterpolations->size()); |
110 EXPECT_FLOAT_EQ(12.5f, getInterpolableNumber(activeInterpolations->at(0))); | 110 EXPECT_FLOAT_EQ(12.5f, getInterpolableNumber(activeInterpolations->at(0))); |
111 | 111 |
112 interpolationEffect->getActiveInterpolations(2, duration, activeInterpolatio
ns); | 112 interpolationEffect->getActiveInterpolations(2, duration, activeInterpolatio
ns); |
113 EXPECT_EQ(1ul, activeInterpolations->size()); | 113 EXPECT_EQ(1ul, activeInterpolations->size()); |
114 EXPECT_FLOAT_EQ(15, getInterpolableNumber(activeInterpolations->at(0))); | 114 EXPECT_FLOAT_EQ(15, getInterpolableNumber(activeInterpolations->at(0))); |
115 } | 115 } |
116 | 116 |
117 } | 117 } |
OLD | NEW |