| 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 "cc/animation/keyframed_animation_curve.h" | 5 #include "cc/animation/keyframed_animation_curve.h" |
| 6 | 6 |
| 7 #include "cc/animation/transform_operations.h" | 7 #include "cc/animation/transform_operations.h" |
| 8 #include "testing/gmock/include/gmock/gmock.h" | 8 #include "testing/gmock/include/gmock/gmock.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "ui/gfx/animation/tween.h" | 10 #include "ui/gfx/animation/tween.h" |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 EXPECT_FLOAT_EQ(6.f, curve->GetValue(1.5f)); | 404 EXPECT_FLOAT_EQ(6.f, curve->GetValue(1.5f)); |
| 405 EXPECT_FLOAT_EQ(8.f, curve->GetValue(2.f)); | 405 EXPECT_FLOAT_EQ(8.f, curve->GetValue(2.f)); |
| 406 EXPECT_FLOAT_EQ(8.f, curve->GetValue(3.f)); | 406 EXPECT_FLOAT_EQ(8.f, curve->GetValue(3.f)); |
| 407 } | 407 } |
| 408 | 408 |
| 409 // Tests that a cubic bezier timing function works as expected. | 409 // Tests that a cubic bezier timing function works as expected. |
| 410 TEST(KeyframedAnimationCurveTest, CubicBezierTimingFunction) { | 410 TEST(KeyframedAnimationCurveTest, CubicBezierTimingFunction) { |
| 411 scoped_ptr<KeyframedFloatAnimationCurve> curve( | 411 scoped_ptr<KeyframedFloatAnimationCurve> curve( |
| 412 KeyframedFloatAnimationCurve::Create()); | 412 KeyframedFloatAnimationCurve::Create()); |
| 413 curve->AddKeyframe(FloatKeyframe::Create( | 413 curve->AddKeyframe(FloatKeyframe::Create( |
| 414 0.0, | 414 0.0, 0.f, CubicBezierTimingFunction::Create(0.25f, 0.f, 0.75f, 1.f))); |
| 415 0.f, | |
| 416 CubicBezierTimingFunction::Create(0.25f, 0.f, 0.75f, 1.f) | |
| 417 .PassAs<TimingFunction>())); | |
| 418 curve->AddKeyframe( | 415 curve->AddKeyframe( |
| 419 FloatKeyframe::Create(1.0, 1.f, scoped_ptr<TimingFunction>())); | 416 FloatKeyframe::Create(1.0, 1.f, scoped_ptr<TimingFunction>())); |
| 420 | 417 |
| 421 EXPECT_FLOAT_EQ(0.f, curve->GetValue(0.f)); | 418 EXPECT_FLOAT_EQ(0.f, curve->GetValue(0.f)); |
| 422 EXPECT_LT(0.f, curve->GetValue(0.25f)); | 419 EXPECT_LT(0.f, curve->GetValue(0.25f)); |
| 423 EXPECT_GT(0.25f, curve->GetValue(0.25f)); | 420 EXPECT_GT(0.25f, curve->GetValue(0.25f)); |
| 424 EXPECT_NEAR(curve->GetValue(0.5f), 0.5f, 0.00015f); | 421 EXPECT_NEAR(curve->GetValue(0.5f), 0.5f, 0.00015f); |
| 425 EXPECT_LT(0.75f, curve->GetValue(0.75f)); | 422 EXPECT_LT(0.75f, curve->GetValue(0.75f)); |
| 426 EXPECT_GT(1.f, curve->GetValue(0.75f)); | 423 EXPECT_GT(1.f, curve->GetValue(0.75f)); |
| 427 EXPECT_FLOAT_EQ(1.f, curve->GetValue(1.f)); | 424 EXPECT_FLOAT_EQ(1.f, curve->GetValue(1.f)); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 TransformOperations operations3; | 537 TransformOperations operations3; |
| 541 operations3.AppendRotate(1.f, 0.f, 0.f, 90.f); | 538 operations3.AppendRotate(1.f, 0.f, 0.f, 90.f); |
| 542 curve->AddKeyframe(TransformKeyframe::Create( | 539 curve->AddKeyframe(TransformKeyframe::Create( |
| 543 3.0, operations3, EaseTimingFunction::Create())); | 540 3.0, operations3, EaseTimingFunction::Create())); |
| 544 | 541 |
| 545 EXPECT_FALSE(curve->MaximumScale(&maximum_scale)); | 542 EXPECT_FALSE(curve->MaximumScale(&maximum_scale)); |
| 546 } | 543 } |
| 547 | 544 |
| 548 } // namespace | 545 } // namespace |
| 549 } // namespace cc | 546 } // namespace cc |
| OLD | NEW |