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

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

Issue 833093002: CC: Allow cubic-bezier timing inputs outside the range [0, 1] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@0
Patch Set: Trigger CQ build Created 5 years, 11 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
« 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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 EXPECT_NEAR(function.Slope(0.65), 1.26751, epsilon); 157 EXPECT_NEAR(function.Slope(0.65), 1.26751, epsilon);
158 EXPECT_NEAR(function.Slope(0.7), 1.21239, epsilon); 158 EXPECT_NEAR(function.Slope(0.7), 1.21239, epsilon);
159 EXPECT_NEAR(function.Slope(0.75), 1.13576, epsilon); 159 EXPECT_NEAR(function.Slope(0.75), 1.13576, epsilon);
160 EXPECT_NEAR(function.Slope(0.8), 1.03184, epsilon); 160 EXPECT_NEAR(function.Slope(0.8), 1.03184, epsilon);
161 EXPECT_NEAR(function.Slope(0.85), 0.89121, epsilon); 161 EXPECT_NEAR(function.Slope(0.85), 0.89121, epsilon);
162 EXPECT_NEAR(function.Slope(0.9), 0.69778, epsilon); 162 EXPECT_NEAR(function.Slope(0.9), 0.69778, epsilon);
163 EXPECT_NEAR(function.Slope(0.95), 0.42170, epsilon); 163 EXPECT_NEAR(function.Slope(0.95), 0.42170, epsilon);
164 EXPECT_NEAR(function.Slope(1), 0, epsilon); 164 EXPECT_NEAR(function.Slope(1), 0, epsilon);
165 } 165 }
166 166
167 TEST(CubicBezierTest, InputOutOfRange) {
168 CubicBezier simple(0.5, 1.0, 0.5, 1.0);
169 EXPECT_EQ(-2.0, simple.Solve(-1.0));
170 EXPECT_EQ(1.0, simple.Solve(2.0));
171
172 CubicBezier coincidentEndpoints(0.0, 0.0, 1.0, 1.0);
173 EXPECT_EQ(-1.0, coincidentEndpoints.Solve(-1.0));
174 EXPECT_EQ(2.0, coincidentEndpoints.Solve(2.0));
175
176 CubicBezier verticalGradient(0.0, 1.0, 1.0, 0.0);
177 EXPECT_EQ(0.0, verticalGradient.Solve(-1.0));
178 EXPECT_EQ(1.0, verticalGradient.Solve(2.0));
179
180 CubicBezier distinctEndpoints(0.1, 0.2, 0.8, 0.8);
181 EXPECT_EQ(-2.0, distinctEndpoints.Solve(-1.0));
182 EXPECT_EQ(2.0, distinctEndpoints.Solve(2.0));
183
184 CubicBezier coincidentEndpoint(0.0, 0.0, 0.8, 0.8);
185 EXPECT_EQ(-1.0, coincidentEndpoint.Solve(-1.0));
186 EXPECT_EQ(2.0, coincidentEndpoint.Solve(2.0));
187
188 CubicBezier threeCoincidentPoints(0.0, 0.0, 0.0, 0.0);
189 EXPECT_EQ(0, threeCoincidentPoints.Solve(-1.0));
190 EXPECT_EQ(2.0, threeCoincidentPoints.Solve(2.0));
191
192 }
193
167 } // namespace 194 } // namespace
168 } // namespace gfx 195 } // 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