Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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)); | |
|
Ian Vollick
2015/01/05 15:36:04
It'd be nice to have a test where one of the endpo
loyso (OOO)
2015/01/06 02:24:53
As I mentioned above, this is a port of tests from
| |
| 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 | |
| 167 } // namespace | 185 } // namespace |
| 168 } // namespace gfx | 186 } // namespace gfx |
| OLD | NEW |