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

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

Issue 1120003002: [Oilpan] Migrate most classes under core/animations to Oilpan heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Resize expect size of Persistent Created 5 years, 6 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 "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 {
11 11
12 namespace { 12 namespace {
13 13
14 class SampleInterpolation : public Interpolation { 14 class SampleInterpolation : public Interpolation {
15 public: 15 public:
16 static PassRefPtrWillBeRawPtr<Interpolation> create(PassOwnPtrWillBeRawPtr<I nterpolableValue> start, PassOwnPtrWillBeRawPtr<InterpolableValue> end) 16 static Interpolation* create(InterpolableValue* start, InterpolableValue* en d)
17 { 17 {
18 return adoptRefWillBeNoop(new SampleInterpolation(start, end)); 18 return new SampleInterpolation(start, end);
19 } 19 }
20 20
21 virtual PropertyHandle property() const override 21 virtual PropertyHandle property() const override
22 { 22 {
23 return PropertyHandle(CSSPropertyBackgroundColor); 23 return PropertyHandle(CSSPropertyBackgroundColor);
24 } 24 }
25 private: 25 private:
26 SampleInterpolation(PassOwnPtrWillBeRawPtr<InterpolableValue> start, PassOwn PtrWillBeRawPtr<InterpolableValue> end) 26 SampleInterpolation(InterpolableValue* start, InterpolableValue* end)
27 : Interpolation(start, end) 27 : Interpolation(start, end)
28 { 28 {
29 } 29 }
30 }; 30 };
31 31
32 const double duration = 1.0; 32 const double duration = 1.0;
33 33
34 } // namespace 34 } // namespace
35 35
36 class AnimationInterpolationEffectTest : public ::testing::Test { 36 class AnimationInterpolationEffectTest : public ::testing::Test {
37 protected: 37 protected:
38 InterpolableValue* interpolationValue(Interpolation& interpolation) 38 InterpolableValue* interpolationValue(Interpolation& interpolation)
39 { 39 {
40 return interpolation.getCachedValueForTesting(); 40 return interpolation.getCachedValueForTesting();
41 } 41 }
42 42
43 double getInterpolableNumber(PassRefPtrWillBeRawPtr<Interpolation> value) 43 double getInterpolableNumber(Interpolation* value)
44 { 44 {
45 return toInterpolableNumber(interpolationValue(*value.get()))->value(); 45 return toInterpolableNumber(interpolationValue(*value))->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)), RefPtr<TimingFunction>(), 0, 1, -1, 2);
53 RefPtr<TimingFunction>(), 0, 1, -1, 2);
54 53
55 OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation>>> acti veInterpolations = nullptr; 54 HeapVector<Member<Interpolation>>* activeInterpolations = nullptr;
56 interpolationEffect->getActiveInterpolations(-2, duration, activeInterpolati ons); 55 interpolationEffect->getActiveInterpolations(-2, duration, activeInterpolati ons);
57 EXPECT_EQ(0ul, activeInterpolations->size()); 56 EXPECT_EQ(0ul, activeInterpolations->size());
58 57
59 interpolationEffect->getActiveInterpolations(-0.5, duration, activeInterpola tions); 58 interpolationEffect->getActiveInterpolations(-0.5, duration, activeInterpola tions);
60 EXPECT_EQ(1ul, activeInterpolations->size()); 59 EXPECT_EQ(1ul, activeInterpolations->size());
61 EXPECT_EQ(-5, getInterpolableNumber(activeInterpolations->at(0))); 60 EXPECT_EQ(-5, getInterpolableNumber(activeInterpolations->at(0)));
62 61
63 interpolationEffect->getActiveInterpolations(0.5, duration, activeInterpolat ions); 62 interpolationEffect->getActiveInterpolations(0.5, duration, activeInterpolat ions);
64 EXPECT_EQ(1ul, activeInterpolations->size()); 63 EXPECT_EQ(1ul, activeInterpolations->size());
65 EXPECT_FLOAT_EQ(5, getInterpolableNumber(activeInterpolations->at(0))); 64 EXPECT_FLOAT_EQ(5, getInterpolableNumber(activeInterpolations->at(0)));
66 65
67 interpolationEffect->getActiveInterpolations(1.5, duration, activeInterpolat ions); 66 interpolationEffect->getActiveInterpolations(1.5, duration, activeInterpolat ions);
68 EXPECT_EQ(1ul, activeInterpolations->size()); 67 EXPECT_EQ(1ul, activeInterpolations->size());
69 EXPECT_FLOAT_EQ(15, getInterpolableNumber(activeInterpolations->at(0))); 68 EXPECT_FLOAT_EQ(15, getInterpolableNumber(activeInterpolations->at(0)));
70 69
71 interpolationEffect->getActiveInterpolations(3, duration, activeInterpolatio ns); 70 interpolationEffect->getActiveInterpolations(3, duration, activeInterpolatio ns);
72 EXPECT_EQ(0ul, activeInterpolations->size()); 71 EXPECT_EQ(0ul, activeInterpolations->size());
73 } 72 }
74 73
75 TEST_F(AnimationInterpolationEffectTest, MultipleInterpolations) 74 TEST_F(AnimationInterpolationEffectTest, MultipleInterpolations)
76 { 75 {
77 RefPtrWillBeRawPtr<InterpolationEffect> interpolationEffect = InterpolationE ffect::create(); 76 InterpolationEffect* interpolationEffect = InterpolationEffect::create();
78 interpolationEffect->addInterpolation(SampleInterpolation::create(Interpolab leNumber::create(10), InterpolableNumber::create(15)), 77 interpolationEffect->addInterpolation(SampleInterpolation::create(Interpolab leNumber::create(10), InterpolableNumber::create(15)),
79 RefPtr<TimingFunction>(), 1, 2, 1, 3); 78 RefPtr<TimingFunction>(), 1, 2, 1, 3);
80 interpolationEffect->addInterpolation(SampleInterpolation::create(Interpolab leNumber::create(0), InterpolableNumber::create(1)), 79 interpolationEffect->addInterpolation(SampleInterpolation::create(Interpolab leNumber::create(0), InterpolableNumber::create(1)),
81 LinearTimingFunction::shared(), 0, 1, 0, 1); 80 LinearTimingFunction::shared(), 0, 1, 0, 1);
82 interpolationEffect->addInterpolation(SampleInterpolation::create(Interpolab leNumber::create(1), InterpolableNumber::create(6)), 81 interpolationEffect->addInterpolation(SampleInterpolation::create(Interpolab leNumber::create(1), InterpolableNumber::create(6)),
83 CubicBezierTimingFunction::preset(CubicBezierTimingFunction::Ease), 0.5, 1.5, 0.5, 1.5); 82 CubicBezierTimingFunction::preset(CubicBezierTimingFunction::Ease), 0.5, 1.5, 0.5, 1.5);
84 83
85 OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation>>> acti veInterpolations = nullptr; 84 HeapVector<Member<Interpolation>>* activeInterpolations = nullptr;
86 interpolationEffect->getActiveInterpolations(-0.5, duration, activeInterpola tions); 85 interpolationEffect->getActiveInterpolations(-0.5, duration, activeInterpola tions);
87 EXPECT_EQ(0ul, activeInterpolations->size()); 86 EXPECT_EQ(0ul, activeInterpolations->size());
88 87
89 interpolationEffect->getActiveInterpolations(0, duration, activeInterpolatio ns); 88 interpolationEffect->getActiveInterpolations(0, duration, activeInterpolatio ns);
90 EXPECT_EQ(1ul, activeInterpolations->size()); 89 EXPECT_EQ(1ul, activeInterpolations->size());
91 EXPECT_FLOAT_EQ(0, getInterpolableNumber(activeInterpolations->at(0))); 90 EXPECT_FLOAT_EQ(0, getInterpolableNumber(activeInterpolations->at(0)));
92 91
93 interpolationEffect->getActiveInterpolations(0.5, duration, activeInterpolat ions); 92 interpolationEffect->getActiveInterpolations(0.5, duration, activeInterpolat ions);
94 EXPECT_EQ(2ul, activeInterpolations->size()); 93 EXPECT_EQ(2ul, activeInterpolations->size());
95 EXPECT_FLOAT_EQ(0.5f, getInterpolableNumber(activeInterpolations->at(0))); 94 EXPECT_FLOAT_EQ(0.5f, getInterpolableNumber(activeInterpolations->at(0)));
(...skipping 12 matching lines...) Expand all
108 interpolationEffect->getActiveInterpolations(1.5, duration, activeInterpolat ions); 107 interpolationEffect->getActiveInterpolations(1.5, duration, activeInterpolat ions);
109 EXPECT_EQ(1ul, activeInterpolations->size()); 108 EXPECT_EQ(1ul, activeInterpolations->size());
110 EXPECT_FLOAT_EQ(12.5f, getInterpolableNumber(activeInterpolations->at(0))); 109 EXPECT_FLOAT_EQ(12.5f, getInterpolableNumber(activeInterpolations->at(0)));
111 110
112 interpolationEffect->getActiveInterpolations(2, duration, activeInterpolatio ns); 111 interpolationEffect->getActiveInterpolations(2, duration, activeInterpolatio ns);
113 EXPECT_EQ(1ul, activeInterpolations->size()); 112 EXPECT_EQ(1ul, activeInterpolations->size());
114 EXPECT_FLOAT_EQ(15, getInterpolableNumber(activeInterpolations->at(0))); 113 EXPECT_FLOAT_EQ(15, getInterpolableNumber(activeInterpolations->at(0)));
115 } 114 }
116 115
117 } 116 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698