| 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 "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "cc/timing_function.h" | 8 #include "cc/timing_function.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "third_party/WebKit/Source/Platform/chromium/public/WebTransformationMa
trix.h" | 10 #include "third_party/WebKit/Source/Platform/chromium/public/WebTransformationMa
trix.h" |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 scoped_ptr<WebTransformAnimationCurve> curve(new WebTransformAnimationCurveI
mpl); | 129 scoped_ptr<WebTransformAnimationCurve> curve(new WebTransformAnimationCurveI
mpl); |
| 130 WebKit::WebTransformOperations operations1; | 130 WebKit::WebTransformOperations operations1; |
| 131 operations1.appendTranslate(0, 0, 0); | 131 operations1.appendTranslate(0, 0, 0); |
| 132 WebKit::WebTransformOperations operations2; | 132 WebKit::WebTransformOperations operations2; |
| 133 operations2.appendTranslate(1, 0, 0); | 133 operations2.appendTranslate(1, 0, 0); |
| 134 curve->add(WebTransformKeyframe(0, operations1), 0.25, 0, 0.75, 1); | 134 curve->add(WebTransformKeyframe(0, operations1), 0.25, 0, 0.75, 1); |
| 135 curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFu
nctionTypeLinear); | 135 curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFu
nctionTypeLinear); |
| 136 EXPECT_FLOAT_EQ(0, curve->getValue(0).m41()); | 136 EXPECT_FLOAT_EQ(0, curve->getValue(0).m41()); |
| 137 EXPECT_LT(0, curve->getValue(0.25).m41()); | 137 EXPECT_LT(0, curve->getValue(0.25).m41()); |
| 138 EXPECT_GT(0.25, curve->getValue(0.25).m41()); | 138 EXPECT_GT(0.25, curve->getValue(0.25).m41()); |
| 139 EXPECT_FLOAT_EQ(0.5, curve->getValue(0.5).m41()); | 139 EXPECT_NEAR(curve->getValue(0.5).m41(), 0.5, 0.00015); |
| 140 EXPECT_LT(0.75, curve->getValue(0.75).m41()); | 140 EXPECT_LT(0.75, curve->getValue(0.75).m41()); |
| 141 EXPECT_GT(1, curve->getValue(0.75).m41()); | 141 EXPECT_GT(1, curve->getValue(0.75).m41()); |
| 142 EXPECT_FLOAT_EQ(1, curve->getValue(1).m41()); | 142 EXPECT_FLOAT_EQ(1, curve->getValue(1).m41()); |
| 143 } | 143 } |
| 144 | 144 |
| 145 // Tests that an ease timing function works as expected. | 145 // Tests that an ease timing function works as expected. |
| 146 TEST(WebTransformAnimationCurveTest, EaseTimingFunction) | 146 TEST(WebTransformAnimationCurveTest, EaseTimingFunction) |
| 147 { | 147 { |
| 148 scoped_ptr<WebTransformAnimationCurve> curve(new WebTransformAnimationCurveI
mpl); | 148 scoped_ptr<WebTransformAnimationCurve> curve(new WebTransformAnimationCurveI
mpl); |
| 149 WebKit::WebTransformOperations operations1; | 149 WebKit::WebTransformOperations operations1; |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFu
nctionTypeLinear); | 265 curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFu
nctionTypeLinear); |
| 266 | 266 |
| 267 scoped_ptr<cc::TimingFunction> timingFunction(cc::EaseTimingFunction::create
()); | 267 scoped_ptr<cc::TimingFunction> timingFunction(cc::EaseTimingFunction::create
()); |
| 268 for (int i = 0; i <= 4; ++i) { | 268 for (int i = 0; i <= 4; ++i) { |
| 269 const double time = i * 0.25; | 269 const double time = i * 0.25; |
| 270 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time).m4
1()); | 270 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time).m4
1()); |
| 271 } | 271 } |
| 272 } | 272 } |
| 273 | 273 |
| 274 } // namespace | 274 } // namespace |
| OLD | NEW |