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

Side by Side Diff: ui/gfx/geometry/cubic_bezier_unittest.cc

Issue 393713002: Scroll offset animation curve retargeting. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove workaround. Created 6 years, 5 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
« no previous file with comments | « ui/gfx/geometry/cubic_bezier.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "ui/gfx/geometry/cubic_bezier.h" 5 #include "ui/gfx/geometry/cubic_bezier.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 namespace gfx { 10 namespace gfx {
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 EXPECT_EQ(0, min); 129 EXPECT_EQ(0, min);
130 EXPECT_EQ(1, max); 130 EXPECT_EQ(1, max);
131 131
132 // Derivative has two roots > 1. 132 // Derivative has two roots > 1.
133 function.reset(new CubicBezier(0.25, 0.367, 0.75, 0.7)); 133 function.reset(new CubicBezier(0.25, 0.367, 0.75, 0.7));
134 function->Range(&min, &max); 134 function->Range(&min, &max);
135 EXPECT_EQ(0.f, min); 135 EXPECT_EQ(0.f, min);
136 EXPECT_EQ(1.f, max); 136 EXPECT_EQ(1.f, max);
137 } 137 }
138 138
139 TEST(CubicBezierTest, Slope) {
140 CubicBezier function(0.25, 0.0, 0.75, 1.0);
141
142 double epsilon = 0.00015;
143
144 EXPECT_NEAR(function.Slope(0), 0, epsilon);
145 EXPECT_NEAR(function.Slope(0.05), 0.42170, epsilon);
146 EXPECT_NEAR(function.Slope(0.1), 0.69778, epsilon);
147 EXPECT_NEAR(function.Slope(0.15), 0.89121, epsilon);
148 EXPECT_NEAR(function.Slope(0.2), 1.03184, epsilon);
149 EXPECT_NEAR(function.Slope(0.25), 1.13576, epsilon);
150 EXPECT_NEAR(function.Slope(0.3), 1.21239, epsilon);
151 EXPECT_NEAR(function.Slope(0.35), 1.26751, epsilon);
152 EXPECT_NEAR(function.Slope(0.4), 1.30474, epsilon);
153 EXPECT_NEAR(function.Slope(0.45), 1.32628, epsilon);
154 EXPECT_NEAR(function.Slope(0.5), 1.33333, epsilon);
155 EXPECT_NEAR(function.Slope(0.55), 1.32628, epsilon);
156 EXPECT_NEAR(function.Slope(0.6), 1.30474, epsilon);
157 EXPECT_NEAR(function.Slope(0.65), 1.26751, epsilon);
158 EXPECT_NEAR(function.Slope(0.7), 1.21239, epsilon);
159 EXPECT_NEAR(function.Slope(0.75), 1.13576, epsilon);
160 EXPECT_NEAR(function.Slope(0.8), 1.03184, epsilon);
161 EXPECT_NEAR(function.Slope(0.85), 0.89121, epsilon);
162 EXPECT_NEAR(function.Slope(0.9), 0.69778, epsilon);
163 EXPECT_NEAR(function.Slope(0.95), 0.42170, epsilon);
164 EXPECT_NEAR(function.Slope(1), 0, epsilon);
165 }
166
139 } // namespace 167 } // namespace
140 } // namespace gfx 168 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/geometry/cubic_bezier.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698