OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 | 6 |
7 #include "WebFloatAnimationCurveImpl.h" | 7 #include "WebFloatAnimationCurveImpl.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "cc/timing_function.h" | 9 #include "cc/timing_function.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 EXPECT_FLOAT_EQ(1, curve->getValue(1)); | 109 EXPECT_FLOAT_EQ(1, curve->getValue(1)); |
110 } | 110 } |
111 | 111 |
112 // Tests that an ease timing function works as expected. | 112 // Tests that an ease timing function works as expected. |
113 TEST(WebFloatAnimationCurveTest, EaseTimingFunction) | 113 TEST(WebFloatAnimationCurveTest, EaseTimingFunction) |
114 { | 114 { |
115 scoped_ptr<WebFloatAnimationCurve> curve(new WebFloatAnimationCurveImpl); | 115 scoped_ptr<WebFloatAnimationCurve> curve(new WebFloatAnimationCurveImpl); |
116 curve->add(WebFloatKeyframe(0, 0), WebAnimationCurve::TimingFunctionTypeEase
); | 116 curve->add(WebFloatKeyframe(0, 0), WebAnimationCurve::TimingFunctionTypeEase
); |
117 curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLine
ar); | 117 curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLine
ar); |
118 | 118 |
119 scoped_ptr<cc::CCTimingFunction> timingFunction(cc::CCEaseTimingFunction::cr
eate()); | 119 scoped_ptr<cc::TimingFunction> timingFunction(cc::EaseTimingFunction::create
()); |
120 for (int i = 0; i <= 4; ++i) { | 120 for (int i = 0; i <= 4; ++i) { |
121 const double time = i * 0.25; | 121 const double time = i * 0.25; |
122 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time)); | 122 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time)); |
123 } | 123 } |
124 } | 124 } |
125 | 125 |
126 // Tests using a linear timing function. | 126 // Tests using a linear timing function. |
127 TEST(WebFloatAnimationCurveTest, LinearTimingFunction) | 127 TEST(WebFloatAnimationCurveTest, LinearTimingFunction) |
128 { | 128 { |
129 scoped_ptr<WebFloatAnimationCurve> curve(new WebFloatAnimationCurveImpl); | 129 scoped_ptr<WebFloatAnimationCurve> curve(new WebFloatAnimationCurveImpl); |
130 curve->add(WebFloatKeyframe(0, 0), WebAnimationCurve::TimingFunctionTypeLine
ar); | 130 curve->add(WebFloatKeyframe(0, 0), WebAnimationCurve::TimingFunctionTypeLine
ar); |
131 curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLine
ar); | 131 curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLine
ar); |
132 | 132 |
133 for (int i = 0; i <= 4; ++i) { | 133 for (int i = 0; i <= 4; ++i) { |
134 const double time = i * 0.25; | 134 const double time = i * 0.25; |
135 EXPECT_FLOAT_EQ(time, curve->getValue(time)); | 135 EXPECT_FLOAT_EQ(time, curve->getValue(time)); |
136 } | 136 } |
137 } | 137 } |
138 | 138 |
139 // Tests that an ease in timing function works as expected. | 139 // Tests that an ease in timing function works as expected. |
140 TEST(WebFloatAnimationCurveTest, EaseInTimingFunction) | 140 TEST(WebFloatAnimationCurveTest, EaseInTimingFunction) |
141 { | 141 { |
142 scoped_ptr<WebFloatAnimationCurve> curve(new WebFloatAnimationCurveImpl); | 142 scoped_ptr<WebFloatAnimationCurve> curve(new WebFloatAnimationCurveImpl); |
143 curve->add(WebFloatKeyframe(0, 0), WebAnimationCurve::TimingFunctionTypeEase
In); | 143 curve->add(WebFloatKeyframe(0, 0), WebAnimationCurve::TimingFunctionTypeEase
In); |
144 curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLine
ar); | 144 curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLine
ar); |
145 | 145 |
146 scoped_ptr<cc::CCTimingFunction> timingFunction(cc::CCEaseInTimingFunction::
create()); | 146 scoped_ptr<cc::TimingFunction> timingFunction(cc::EaseInTimingFunction::crea
te()); |
147 for (int i = 0; i <= 4; ++i) { | 147 for (int i = 0; i <= 4; ++i) { |
148 const double time = i * 0.25; | 148 const double time = i * 0.25; |
149 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time)); | 149 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time)); |
150 } | 150 } |
151 } | 151 } |
152 | 152 |
153 // Tests that an ease in timing function works as expected. | 153 // Tests that an ease in timing function works as expected. |
154 TEST(WebFloatAnimationCurveTest, EaseOutTimingFunction) | 154 TEST(WebFloatAnimationCurveTest, EaseOutTimingFunction) |
155 { | 155 { |
156 scoped_ptr<WebFloatAnimationCurve> curve(new WebFloatAnimationCurveImpl); | 156 scoped_ptr<WebFloatAnimationCurve> curve(new WebFloatAnimationCurveImpl); |
157 curve->add(WebFloatKeyframe(0, 0), WebAnimationCurve::TimingFunctionTypeEase
Out); | 157 curve->add(WebFloatKeyframe(0, 0), WebAnimationCurve::TimingFunctionTypeEase
Out); |
158 curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLine
ar); | 158 curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLine
ar); |
159 | 159 |
160 scoped_ptr<cc::CCTimingFunction> timingFunction(cc::CCEaseOutTimingFunction:
:create()); | 160 scoped_ptr<cc::TimingFunction> timingFunction(cc::EaseOutTimingFunction::cre
ate()); |
161 for (int i = 0; i <= 4; ++i) { | 161 for (int i = 0; i <= 4; ++i) { |
162 const double time = i * 0.25; | 162 const double time = i * 0.25; |
163 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time)); | 163 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time)); |
164 } | 164 } |
165 } | 165 } |
166 | 166 |
167 // Tests that an ease in timing function works as expected. | 167 // Tests that an ease in timing function works as expected. |
168 TEST(WebFloatAnimationCurveTest, EaseInOutTimingFunction) | 168 TEST(WebFloatAnimationCurveTest, EaseInOutTimingFunction) |
169 { | 169 { |
170 scoped_ptr<WebFloatAnimationCurve> curve(new WebFloatAnimationCurveImpl); | 170 scoped_ptr<WebFloatAnimationCurve> curve(new WebFloatAnimationCurveImpl); |
171 curve->add(WebFloatKeyframe(0, 0), WebAnimationCurve::TimingFunctionTypeEase
InOut); | 171 curve->add(WebFloatKeyframe(0, 0), WebAnimationCurve::TimingFunctionTypeEase
InOut); |
172 curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLine
ar); | 172 curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLine
ar); |
173 | 173 |
174 scoped_ptr<cc::CCTimingFunction> timingFunction(cc::CCEaseInOutTimingFunctio
n::create()); | 174 scoped_ptr<cc::TimingFunction> timingFunction(cc::EaseInOutTimingFunction::c
reate()); |
175 for (int i = 0; i <= 4; ++i) { | 175 for (int i = 0; i <= 4; ++i) { |
176 const double time = i * 0.25; | 176 const double time = i * 0.25; |
177 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time)); | 177 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time)); |
178 } | 178 } |
179 } | 179 } |
180 | 180 |
181 // Tests that an ease in timing function works as expected. | 181 // Tests that an ease in timing function works as expected. |
182 TEST(WebFloatAnimationCurveTest, CustomBezierTimingFunction) | 182 TEST(WebFloatAnimationCurveTest, CustomBezierTimingFunction) |
183 { | 183 { |
184 scoped_ptr<WebFloatAnimationCurve> curve(new WebFloatAnimationCurveImpl); | 184 scoped_ptr<WebFloatAnimationCurve> curve(new WebFloatAnimationCurveImpl); |
185 double x1 = 0.3; | 185 double x1 = 0.3; |
186 double y1 = 0.2; | 186 double y1 = 0.2; |
187 double x2 = 0.8; | 187 double x2 = 0.8; |
188 double y2 = 0.7; | 188 double y2 = 0.7; |
189 curve->add(WebFloatKeyframe(0, 0), x1, y1, x2, y2); | 189 curve->add(WebFloatKeyframe(0, 0), x1, y1, x2, y2); |
190 curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLine
ar); | 190 curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLine
ar); |
191 | 191 |
192 scoped_ptr<cc::CCTimingFunction> timingFunction(cc::CCCubicBezierTimingFunct
ion::create(x1, y1, x2, y2)); | 192 scoped_ptr<cc::TimingFunction> timingFunction(cc::CubicBezierTimingFunction:
:create(x1, y1, x2, y2)); |
193 for (int i = 0; i <= 4; ++i) { | 193 for (int i = 0; i <= 4; ++i) { |
194 const double time = i * 0.25; | 194 const double time = i * 0.25; |
195 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time)); | 195 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time)); |
196 } | 196 } |
197 } | 197 } |
198 | 198 |
199 // Tests that the default timing function is indeed ease. | 199 // Tests that the default timing function is indeed ease. |
200 TEST(WebFloatAnimationCurveTest, DefaultTimingFunction) | 200 TEST(WebFloatAnimationCurveTest, DefaultTimingFunction) |
201 { | 201 { |
202 scoped_ptr<WebFloatAnimationCurve> curve(new WebFloatAnimationCurveImpl); | 202 scoped_ptr<WebFloatAnimationCurve> curve(new WebFloatAnimationCurveImpl); |
203 curve->add(WebFloatKeyframe(0, 0)); | 203 curve->add(WebFloatKeyframe(0, 0)); |
204 curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLine
ar); | 204 curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLine
ar); |
205 | 205 |
206 scoped_ptr<cc::CCTimingFunction> timingFunction(cc::CCEaseTimingFunction::cr
eate()); | 206 scoped_ptr<cc::TimingFunction> timingFunction(cc::EaseTimingFunction::create
()); |
207 for (int i = 0; i <= 4; ++i) { | 207 for (int i = 0; i <= 4; ++i) { |
208 const double time = i * 0.25; | 208 const double time = i * 0.25; |
209 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time)); | 209 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time)); |
210 } | 210 } |
211 } | 211 } |
212 | 212 |
213 } // namespace | 213 } // namespace |
OLD | NEW |