| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/animation/tween.h" | 5 #include "ui/gfx/animation/tween.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #if defined(OS_WIN) | |
| 10 #include <float.h> | |
| 11 #endif | |
| 12 | |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include "ui/gfx/test/gfx_util.h" | 10 #include "ui/gfx/test/gfx_util.h" |
| 15 | 11 |
| 16 namespace gfx { | 12 namespace gfx { |
| 17 namespace { | 13 namespace { |
| 18 | 14 |
| 19 double next_double(double d) { | 15 double next_double(double d) { |
| 20 #if defined(OS_WIN) | |
| 21 return _nextafter(d, d + 1); | |
| 22 #else | |
| 23 // Step two units of least precision towards positive infinity. On some 32 | 16 // Step two units of least precision towards positive infinity. On some 32 |
| 24 // bit x86 compilers a single step was not enough due to loss of precision in | 17 // bit x86 compilers a single step was not enough due to loss of precision in |
| 25 // optimized code. | 18 // optimized code. |
| 26 return nextafter(nextafter(d, d + 1), d + 1); | 19 return nextafter(nextafter(d, d + 1), d + 1); |
| 27 #endif | |
| 28 } | 20 } |
| 29 | 21 |
| 30 // Validates that the same interpolations are made as in Blink. | 22 // Validates that the same interpolations are made as in Blink. |
| 31 TEST(TweenTest, ColorValueBetween) { | 23 TEST(TweenTest, ColorValueBetween) { |
| 32 // From blink's AnimatableColorTest. | 24 // From blink's AnimatableColorTest. |
| 33 EXPECT_SKCOLOR_EQ(0xFF00FF00, | 25 EXPECT_SKCOLOR_EQ(0xFF00FF00, |
| 34 Tween::ColorValueBetween(-10.0, 0xFF00FF00, 0xFF00FF00)); | 26 Tween::ColorValueBetween(-10.0, 0xFF00FF00, 0xFF00FF00)); |
| 35 EXPECT_SKCOLOR_EQ(0xFF00FF00, | 27 EXPECT_SKCOLOR_EQ(0xFF00FF00, |
| 36 Tween::ColorValueBetween(-10.0, 0xFF00FF00, 0xFFFF00FF)); | 28 Tween::ColorValueBetween(-10.0, 0xFF00FF00, 0xFFFF00FF)); |
| 37 EXPECT_SKCOLOR_EQ(0xFF00FF00, | 29 EXPECT_SKCOLOR_EQ(0xFF00FF00, |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 EXPECT_EQ(-1, Tween::LinearIntValueBetween(2.5 / 4.0, -2, 0)); | 122 EXPECT_EQ(-1, Tween::LinearIntValueBetween(2.5 / 4.0, -2, 0)); |
| 131 EXPECT_EQ(-1, Tween::LinearIntValueBetween(2.99 / 4.0, -2, 0)); | 123 EXPECT_EQ(-1, Tween::LinearIntValueBetween(2.99 / 4.0, -2, 0)); |
| 132 | 124 |
| 133 EXPECT_EQ(0, Tween::LinearIntValueBetween(3.0 / 4.0, -2, 0)); | 125 EXPECT_EQ(0, Tween::LinearIntValueBetween(3.0 / 4.0, -2, 0)); |
| 134 EXPECT_EQ(0, Tween::LinearIntValueBetween(3.5 / 4.0, -2, 0)); | 126 EXPECT_EQ(0, Tween::LinearIntValueBetween(3.5 / 4.0, -2, 0)); |
| 135 EXPECT_EQ(0, Tween::LinearIntValueBetween(4.0 / 4.0, -2, 0)); | 127 EXPECT_EQ(0, Tween::LinearIntValueBetween(4.0 / 4.0, -2, 0)); |
| 136 } | 128 } |
| 137 | 129 |
| 138 } // namespace | 130 } // namespace |
| 139 } // namespace gfx | 131 } // namespace gfx |
| OLD | NEW |