| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |