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 "core/animation/InterpolationEffect.h" | 5 #include "core/animation/InterpolationEffect.h" |
6 | 6 |
| 7 #include "core/animation/LegacyStyleInterpolation.h" |
7 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
8 #include <memory> | 9 #include <memory> |
9 | 10 |
10 namespace blink { | 11 namespace blink { |
11 | 12 |
12 namespace { | 13 namespace { |
13 | 14 |
14 class SampleInterpolation : public Interpolation { | 15 class SampleInterpolation : public LegacyStyleInterpolation { |
15 public: | 16 public: |
16 static PassRefPtr<Interpolation> create( | 17 static PassRefPtr<Interpolation> create( |
17 std::unique_ptr<InterpolableValue> start, | 18 std::unique_ptr<InterpolableValue> start, |
18 std::unique_ptr<InterpolableValue> end) { | 19 std::unique_ptr<InterpolableValue> end) { |
19 return adoptRef(new SampleInterpolation(std::move(start), std::move(end))); | 20 return adoptRef(new SampleInterpolation(std::move(start), std::move(end))); |
20 } | 21 } |
21 | 22 |
22 PropertyHandle getProperty() const override { | |
23 return PropertyHandle(CSSPropertyBackgroundColor); | |
24 } | |
25 | |
26 private: | 23 private: |
27 SampleInterpolation(std::unique_ptr<InterpolableValue> start, | 24 SampleInterpolation(std::unique_ptr<InterpolableValue> start, |
28 std::unique_ptr<InterpolableValue> end) | 25 std::unique_ptr<InterpolableValue> end) |
29 : Interpolation(std::move(start), std::move(end)) {} | 26 : LegacyStyleInterpolation(std::move(start), |
| 27 std::move(end), |
| 28 CSSPropertyBackgroundColor) {} |
30 }; | 29 }; |
31 | 30 |
32 const double duration = 1.0; | 31 const double duration = 1.0; |
33 | 32 |
34 } // namespace | 33 } // namespace |
35 | 34 |
36 class AnimationInterpolationEffectTest : public ::testing::Test { | 35 class AnimationInterpolationEffectTest : public ::testing::Test { |
37 protected: | 36 protected: |
38 InterpolableValue* interpolationValue(Interpolation& interpolation) { | 37 InterpolableValue* interpolationValue(Interpolation& interpolation) { |
39 return interpolation.getCachedValueForTesting(); | 38 return interpolation.getCachedValueForTesting(); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 EXPECT_EQ(1ul, activeInterpolations.size()); | 127 EXPECT_EQ(1ul, activeInterpolations.size()); |
129 EXPECT_FLOAT_EQ(12.5f, getInterpolableNumber(activeInterpolations.at(0))); | 128 EXPECT_FLOAT_EQ(12.5f, getInterpolableNumber(activeInterpolations.at(0))); |
130 | 129 |
131 interpolationEffect.getActiveInterpolations(2, duration, | 130 interpolationEffect.getActiveInterpolations(2, duration, |
132 activeInterpolations); | 131 activeInterpolations); |
133 EXPECT_EQ(1ul, activeInterpolations.size()); | 132 EXPECT_EQ(1ul, activeInterpolations.size()); |
134 EXPECT_FLOAT_EQ(15, getInterpolableNumber(activeInterpolations.at(0))); | 133 EXPECT_FLOAT_EQ(15, getInterpolableNumber(activeInterpolations.at(0))); |
135 } | 134 } |
136 | 135 |
137 } // namespace blink | 136 } // namespace blink |
OLD | NEW |