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

Side by Side Diff: webkit/compositor_bindings/WebTransformAnimationCurveTest.cpp

Issue 11189043: cc: Rename cc classes and members to match filenames (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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 | Annotate | Revision Log
OLDNEW
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 "WebTransformAnimationCurveImpl.h" 7 #include "WebTransformAnimationCurveImpl.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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 TEST(WebTransformAnimationCurveTest, EaseTimingFunction) 146 TEST(WebTransformAnimationCurveTest, EaseTimingFunction)
147 { 147 {
148 scoped_ptr<WebTransformAnimationCurve> curve(new WebTransformAnimationCurveI mpl); 148 scoped_ptr<WebTransformAnimationCurve> curve(new WebTransformAnimationCurveI mpl);
149 WebKit::WebTransformOperations operations1; 149 WebKit::WebTransformOperations operations1;
150 operations1.appendTranslate(0, 0, 0); 150 operations1.appendTranslate(0, 0, 0);
151 WebKit::WebTransformOperations operations2; 151 WebKit::WebTransformOperations operations2;
152 operations2.appendTranslate(1, 0, 0); 152 operations2.appendTranslate(1, 0, 0);
153 curve->add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFu nctionTypeEase); 153 curve->add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFu nctionTypeEase);
154 curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFu nctionTypeLinear); 154 curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFu nctionTypeLinear);
155 155
156 scoped_ptr<cc::CCTimingFunction> timingFunction(cc::CCEaseTimingFunction::cr eate()); 156 scoped_ptr<cc::TimingFunction> timingFunction(cc::EaseTimingFunction::create ());
157 for (int i = 0; i <= 4; ++i) { 157 for (int i = 0; i <= 4; ++i) {
158 const double time = i * 0.25; 158 const double time = i * 0.25;
159 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time).m4 1()); 159 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time).m4 1());
160 } 160 }
161 } 161 }
162 162
163 // Tests using a linear timing function. 163 // Tests using a linear timing function.
164 TEST(WebTransformAnimationCurveTest, LinearTimingFunction) 164 TEST(WebTransformAnimationCurveTest, LinearTimingFunction)
165 { 165 {
166 scoped_ptr<WebTransformAnimationCurve> curve(new WebTransformAnimationCurveI mpl); 166 scoped_ptr<WebTransformAnimationCurve> curve(new WebTransformAnimationCurveI mpl);
(...skipping 14 matching lines...) Expand all
181 TEST(WebTransformAnimationCurveTest, EaseInTimingFunction) 181 TEST(WebTransformAnimationCurveTest, EaseInTimingFunction)
182 { 182 {
183 scoped_ptr<WebTransformAnimationCurve> curve(new WebTransformAnimationCurveI mpl); 183 scoped_ptr<WebTransformAnimationCurve> curve(new WebTransformAnimationCurveI mpl);
184 WebKit::WebTransformOperations operations1; 184 WebKit::WebTransformOperations operations1;
185 operations1.appendTranslate(0, 0, 0); 185 operations1.appendTranslate(0, 0, 0);
186 WebKit::WebTransformOperations operations2; 186 WebKit::WebTransformOperations operations2;
187 operations2.appendTranslate(1, 0, 0); 187 operations2.appendTranslate(1, 0, 0);
188 curve->add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFu nctionTypeEaseIn); 188 curve->add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFu nctionTypeEaseIn);
189 curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFu nctionTypeLinear); 189 curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFu nctionTypeLinear);
190 190
191 scoped_ptr<cc::CCTimingFunction> timingFunction(cc::CCEaseInTimingFunction:: create()); 191 scoped_ptr<cc::TimingFunction> timingFunction(cc::EaseInTimingFunction::crea te());
192 for (int i = 0; i <= 4; ++i) { 192 for (int i = 0; i <= 4; ++i) {
193 const double time = i * 0.25; 193 const double time = i * 0.25;
194 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time).m4 1()); 194 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time).m4 1());
195 } 195 }
196 } 196 }
197 197
198 // Tests that an ease in timing function works as expected. 198 // Tests that an ease in timing function works as expected.
199 TEST(WebTransformAnimationCurveTest, EaseOutTimingFunction) 199 TEST(WebTransformAnimationCurveTest, EaseOutTimingFunction)
200 { 200 {
201 scoped_ptr<WebTransformAnimationCurve> curve(new WebTransformAnimationCurveI mpl); 201 scoped_ptr<WebTransformAnimationCurve> curve(new WebTransformAnimationCurveI mpl);
202 WebKit::WebTransformOperations operations1; 202 WebKit::WebTransformOperations operations1;
203 operations1.appendTranslate(0, 0, 0); 203 operations1.appendTranslate(0, 0, 0);
204 WebKit::WebTransformOperations operations2; 204 WebKit::WebTransformOperations operations2;
205 operations2.appendTranslate(1, 0, 0); 205 operations2.appendTranslate(1, 0, 0);
206 curve->add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFu nctionTypeEaseOut); 206 curve->add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFu nctionTypeEaseOut);
207 curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFu nctionTypeLinear); 207 curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFu nctionTypeLinear);
208 208
209 scoped_ptr<cc::CCTimingFunction> timingFunction(cc::CCEaseOutTimingFunction: :create()); 209 scoped_ptr<cc::TimingFunction> timingFunction(cc::EaseOutTimingFunction::cre ate());
210 for (int i = 0; i <= 4; ++i) { 210 for (int i = 0; i <= 4; ++i) {
211 const double time = i * 0.25; 211 const double time = i * 0.25;
212 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time).m4 1()); 212 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time).m4 1());
213 } 213 }
214 } 214 }
215 215
216 // Tests that an ease in timing function works as expected. 216 // Tests that an ease in timing function works as expected.
217 TEST(WebTransformAnimationCurveTest, EaseInOutTimingFunction) 217 TEST(WebTransformAnimationCurveTest, EaseInOutTimingFunction)
218 { 218 {
219 scoped_ptr<WebTransformAnimationCurve> curve(new WebTransformAnimationCurveI mpl); 219 scoped_ptr<WebTransformAnimationCurve> curve(new WebTransformAnimationCurveI mpl);
220 WebKit::WebTransformOperations operations1; 220 WebKit::WebTransformOperations operations1;
221 operations1.appendTranslate(0, 0, 0); 221 operations1.appendTranslate(0, 0, 0);
222 WebKit::WebTransformOperations operations2; 222 WebKit::WebTransformOperations operations2;
223 operations2.appendTranslate(1, 0, 0); 223 operations2.appendTranslate(1, 0, 0);
224 curve->add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFu nctionTypeEaseInOut); 224 curve->add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFu nctionTypeEaseInOut);
225 curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFu nctionTypeLinear); 225 curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFu nctionTypeLinear);
226 226
227 scoped_ptr<cc::CCTimingFunction> timingFunction(cc::CCEaseInOutTimingFunctio n::create()); 227 scoped_ptr<cc::TimingFunction> timingFunction(cc::EaseInOutTimingFunction::c reate());
228 for (int i = 0; i <= 4; ++i) { 228 for (int i = 0; i <= 4; ++i) {
229 const double time = i * 0.25; 229 const double time = i * 0.25;
230 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time).m4 1()); 230 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time).m4 1());
231 } 231 }
232 } 232 }
233 233
234 // Tests that an ease in timing function works as expected. 234 // Tests that an ease in timing function works as expected.
235 TEST(WebTransformAnimationCurveTest, CustomBezierTimingFunction) 235 TEST(WebTransformAnimationCurveTest, CustomBezierTimingFunction)
236 { 236 {
237 scoped_ptr<WebTransformAnimationCurve> curve(new WebTransformAnimationCurveI mpl); 237 scoped_ptr<WebTransformAnimationCurve> curve(new WebTransformAnimationCurveI mpl);
238 double x1 = 0.3; 238 double x1 = 0.3;
239 double y1 = 0.2; 239 double y1 = 0.2;
240 double x2 = 0.8; 240 double x2 = 0.8;
241 double y2 = 0.7; 241 double y2 = 0.7;
242 WebKit::WebTransformOperations operations1; 242 WebKit::WebTransformOperations operations1;
243 operations1.appendTranslate(0, 0, 0); 243 operations1.appendTranslate(0, 0, 0);
244 WebKit::WebTransformOperations operations2; 244 WebKit::WebTransformOperations operations2;
245 operations2.appendTranslate(1, 0, 0); 245 operations2.appendTranslate(1, 0, 0);
246 curve->add(WebTransformKeyframe(0, operations1), x1, y1, x2, y2); 246 curve->add(WebTransformKeyframe(0, operations1), x1, y1, x2, y2);
247 curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFu nctionTypeLinear); 247 curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFu nctionTypeLinear);
248 248
249 scoped_ptr<cc::CCTimingFunction> timingFunction(cc::CCCubicBezierTimingFunct ion::create(x1, y1, x2, y2)); 249 scoped_ptr<cc::TimingFunction> timingFunction(cc::CubicBezierTimingFunction: :create(x1, y1, x2, y2));
250 for (int i = 0; i <= 4; ++i) { 250 for (int i = 0; i <= 4; ++i) {
251 const double time = i * 0.25; 251 const double time = i * 0.25;
252 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time).m4 1()); 252 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time).m4 1());
253 } 253 }
254 } 254 }
255 255
256 // Tests that the default timing function is indeed ease. 256 // Tests that the default timing function is indeed ease.
257 TEST(WebTransformAnimationCurveTest, DefaultTimingFunction) 257 TEST(WebTransformAnimationCurveTest, DefaultTimingFunction)
258 { 258 {
259 scoped_ptr<WebTransformAnimationCurve> curve(new WebTransformAnimationCurveI mpl); 259 scoped_ptr<WebTransformAnimationCurve> curve(new WebTransformAnimationCurveI mpl);
260 WebKit::WebTransformOperations operations1; 260 WebKit::WebTransformOperations operations1;
261 operations1.appendTranslate(0, 0, 0); 261 operations1.appendTranslate(0, 0, 0);
262 WebKit::WebTransformOperations operations2; 262 WebKit::WebTransformOperations operations2;
263 operations2.appendTranslate(1, 0, 0); 263 operations2.appendTranslate(1, 0, 0);
264 curve->add(WebTransformKeyframe(0, operations1)); 264 curve->add(WebTransformKeyframe(0, operations1));
265 curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFu nctionTypeLinear); 265 curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFu nctionTypeLinear);
266 266
267 scoped_ptr<cc::CCTimingFunction> timingFunction(cc::CCEaseTimingFunction::cr eate()); 267 scoped_ptr<cc::TimingFunction> timingFunction(cc::EaseTimingFunction::create ());
268 for (int i = 0; i <= 4; ++i) { 268 for (int i = 0; i <= 4; ++i) {
269 const double time = i * 0.25; 269 const double time = i * 0.25;
270 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time).m4 1()); 270 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time).m4 1());
271 } 271 }
272 } 272 }
273 273
274 } // namespace 274 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698