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

Side by Side Diff: webkit/compositor_bindings/web_float_animation_curve_unittest.cc

Issue 11359077: cc: Replace the WebCore::UnitBezier class with the SkUnitCubicInterp() method from Skia. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix web unittests Created 8 years, 1 month 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 "web_float_animation_curve_impl.h" 7 #include "web_float_animation_curve_impl.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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 // Tests that a cubic bezier timing function works as expected. 96 // Tests that a cubic bezier timing function works as expected.
97 TEST(WebFloatAnimationCurveTest, CubicBezierTimingFunction) 97 TEST(WebFloatAnimationCurveTest, CubicBezierTimingFunction)
98 { 98 {
99 scoped_ptr<WebFloatAnimationCurve> curve(new WebFloatAnimationCurveImpl); 99 scoped_ptr<WebFloatAnimationCurve> curve(new WebFloatAnimationCurveImpl);
100 curve->add(WebFloatKeyframe(0, 0), 0.25, 0, 0.75, 1); 100 curve->add(WebFloatKeyframe(0, 0), 0.25, 0, 0.75, 1);
101 curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLine ar); 101 curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLine ar);
102 102
103 EXPECT_FLOAT_EQ(0, curve->getValue(0)); 103 EXPECT_FLOAT_EQ(0, curve->getValue(0));
104 EXPECT_LT(0, curve->getValue(0.25)); 104 EXPECT_LT(0, curve->getValue(0.25));
105 EXPECT_GT(0.25, curve->getValue(0.25)); 105 EXPECT_GT(0.25, curve->getValue(0.25));
106 EXPECT_FLOAT_EQ(0.5, curve->getValue(0.5)); 106 EXPECT_NEAR(curve->getValue(0.5), 0.5, 0.00015);
107 EXPECT_LT(0.75, curve->getValue(0.75)); 107 EXPECT_LT(0.75, curve->getValue(0.75));
108 EXPECT_GT(1, curve->getValue(0.75)); 108 EXPECT_GT(1, curve->getValue(0.75));
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 );
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLine ar); 204 curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLine ar);
205 205
206 scoped_ptr<cc::TimingFunction> timingFunction(cc::EaseTimingFunction::create ()); 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
OLDNEW
« no previous file with comments | « cc/timing_function_unittest.cc ('k') | webkit/compositor_bindings/web_transform_animation_curve_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698