Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(113)

Side by Side Diff: third_party/WebKit/Source/core/animation/InterpolationEffectTest.cpp

Issue 2627793002: Remove unused code in InvalidatableInterpolation (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "core/animation/LegacyStyleInterpolation.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include <memory> 9 #include <memory>
10 10
11 namespace blink { 11 namespace blink {
12 12
13 namespace { 13 namespace {
14 14
15 class SampleInterpolation : public LegacyStyleInterpolation { 15 class SampleInterpolation : public LegacyStyleInterpolation {
16 public: 16 public:
17 static PassRefPtr<Interpolation> create( 17 static PassRefPtr<LegacyStyleInterpolation> create(
18 std::unique_ptr<InterpolableValue> start, 18 std::unique_ptr<InterpolableValue> start,
19 std::unique_ptr<InterpolableValue> end) { 19 std::unique_ptr<InterpolableValue> end) {
20 return adoptRef(new SampleInterpolation(std::move(start), std::move(end))); 20 return adoptRef(new SampleInterpolation(std::move(start), std::move(end)));
21 } 21 }
22 22
23 private: 23 private:
24 SampleInterpolation(std::unique_ptr<InterpolableValue> start, 24 SampleInterpolation(std::unique_ptr<InterpolableValue> start,
25 std::unique_ptr<InterpolableValue> end) 25 std::unique_ptr<InterpolableValue> end)
26 : LegacyStyleInterpolation(std::move(start), 26 : LegacyStyleInterpolation(std::move(start),
27 std::move(end), 27 std::move(end),
28 CSSPropertyBackgroundColor) {} 28 CSSPropertyBackgroundColor) {}
29 }; 29 };
30 30
31 const double duration = 1.0; 31 const double duration = 1.0;
32 32
33 } // namespace 33 } // namespace
34 34
35 class AnimationInterpolationEffectTest : public ::testing::Test { 35 class AnimationInterpolationEffectTest : public ::testing::Test {
36 protected: 36 protected:
37 InterpolableValue* interpolationValue(Interpolation& interpolation) { 37 InterpolableValue* interpolationValue(
38 LegacyStyleInterpolation& interpolation) {
38 return interpolation.getCachedValueForTesting(); 39 return interpolation.getCachedValueForTesting();
39 } 40 }
40 41
41 double getInterpolableNumber(PassRefPtr<Interpolation> value) { 42 double getInterpolableNumber(PassRefPtr<Interpolation> value) {
42 return toInterpolableNumber(interpolationValue(*value.get()))->value(); 43 if (value->isLegacyStyleInterpolation()) {
44 LegacyStyleInterpolation& interpolation =
45 toLegacyStyleInterpolation(*value.get());
46 return toInterpolableNumber(interpolationValue(interpolation))->value();
47 }
48 return 0.0;
alancutter (OOO until 2018) 2017/01/11 04:27:33 Remove this branch, don't check just cast, the mac
43 } 49 }
44 }; 50 };
45 51
46 TEST_F(AnimationInterpolationEffectTest, SingleInterpolation) { 52 TEST_F(AnimationInterpolationEffectTest, SingleInterpolation) {
47 InterpolationEffect interpolationEffect; 53 InterpolationEffect interpolationEffect;
48 interpolationEffect.addInterpolation( 54 interpolationEffect.addInterpolation(
49 SampleInterpolation::create(InterpolableNumber::create(0), 55 SampleInterpolation::create(InterpolableNumber::create(0),
50 InterpolableNumber::create(10)), 56 InterpolableNumber::create(10)),
51 RefPtr<TimingFunction>(), 0, 1, -1, 2); 57 RefPtr<TimingFunction>(), 0, 1, -1, 2);
52 58
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 EXPECT_EQ(1ul, activeInterpolations.size()); 133 EXPECT_EQ(1ul, activeInterpolations.size());
128 EXPECT_FLOAT_EQ(12.5f, getInterpolableNumber(activeInterpolations.at(0))); 134 EXPECT_FLOAT_EQ(12.5f, getInterpolableNumber(activeInterpolations.at(0)));
129 135
130 interpolationEffect.getActiveInterpolations(2, duration, 136 interpolationEffect.getActiveInterpolations(2, duration,
131 activeInterpolations); 137 activeInterpolations);
132 EXPECT_EQ(1ul, activeInterpolations.size()); 138 EXPECT_EQ(1ul, activeInterpolations.size());
133 EXPECT_FLOAT_EQ(15, getInterpolableNumber(activeInterpolations.at(0))); 139 EXPECT_FLOAT_EQ(15, getInterpolableNumber(activeInterpolations.at(0)));
134 } 140 }
135 141
136 } // namespace blink 142 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698