| 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 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 CubicBezierTimingFunction::EaseType::EASE))); | 554 CubicBezierTimingFunction::EaseType::EASE))); |
| 555 | 555 |
| 556 gfx::BoxF box(2.f, 3.f, 4.f, 1.f, 3.f, 2.f); | 556 gfx::BoxF box(2.f, 3.f, 4.f, 1.f, 3.f, 2.f); |
| 557 gfx::BoxF bounds; | 557 gfx::BoxF bounds; |
| 558 | 558 |
| 559 EXPECT_TRUE(curve->AnimatedBoundsForBox(box, &bounds)); | 559 EXPECT_TRUE(curve->AnimatedBoundsForBox(box, &bounds)); |
| 560 EXPECT_EQ(gfx::BoxF(2.f, 3.f, 3.f, 5.f, 6.f, 5.f).ToString(), | 560 EXPECT_EQ(gfx::BoxF(2.f, 3.f, 3.f, 5.f, 6.f, 5.f).ToString(), |
| 561 bounds.ToString()); | 561 bounds.ToString()); |
| 562 } | 562 } |
| 563 | 563 |
| 564 // Tests that animations that affect scale are correctly identified. | |
| 565 TEST(KeyframedAnimationCurveTest, AffectsScale) { | |
| 566 std::unique_ptr<KeyframedTransformAnimationCurve> curve( | |
| 567 KeyframedTransformAnimationCurve::Create()); | |
| 568 | |
| 569 TransformOperations operations1; | |
| 570 curve->AddKeyframe( | |
| 571 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); | |
| 572 operations1.AppendTranslate(2.0, 3.0, -1.0); | |
| 573 TransformOperations operations2; | |
| 574 operations2.AppendTranslate(4.0, 1.0, 2.0); | |
| 575 curve->AddKeyframe(TransformKeyframe::Create( | |
| 576 base::TimeDelta::FromSecondsD(1.f), operations2, nullptr)); | |
| 577 | |
| 578 EXPECT_FALSE(curve->AffectsScale()); | |
| 579 | |
| 580 TransformOperations operations3; | |
| 581 operations3.AppendScale(2.f, 2.f, 2.f); | |
| 582 curve->AddKeyframe(TransformKeyframe::Create( | |
| 583 base::TimeDelta::FromSecondsD(2.f), operations3, nullptr)); | |
| 584 | |
| 585 EXPECT_TRUE(curve->AffectsScale()); | |
| 586 | |
| 587 TransformOperations operations4; | |
| 588 operations3.AppendTranslate(2.f, 2.f, 2.f); | |
| 589 curve->AddKeyframe(TransformKeyframe::Create( | |
| 590 base::TimeDelta::FromSecondsD(3.f), operations4, nullptr)); | |
| 591 | |
| 592 EXPECT_TRUE(curve->AffectsScale()); | |
| 593 } | |
| 594 | |
| 595 // Tests that animations that are translations are correctly identified. | 564 // Tests that animations that are translations are correctly identified. |
| 596 TEST(KeyframedAnimationCurveTest, IsTranslation) { | 565 TEST(KeyframedAnimationCurveTest, IsTranslation) { |
| 597 std::unique_ptr<KeyframedTransformAnimationCurve> curve( | 566 std::unique_ptr<KeyframedTransformAnimationCurve> curve( |
| 598 KeyframedTransformAnimationCurve::Create()); | 567 KeyframedTransformAnimationCurve::Create()); |
| 599 | 568 |
| 600 TransformOperations operations1; | 569 TransformOperations operations1; |
| 601 curve->AddKeyframe( | 570 curve->AddKeyframe( |
| 602 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); | 571 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); |
| 603 operations1.AppendTranslate(2.0, 3.0, -1.0); | 572 operations1.AppendTranslate(2.0, 3.0, -1.0); |
| 604 TransformOperations operations2; | 573 TransformOperations operations2; |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 935 curve->GetValue(base::TimeDelta::FromSecondsD(scale * 3.5f)), | 904 curve->GetValue(base::TimeDelta::FromSecondsD(scale * 3.5f)), |
| 936 0.01f); | 905 0.01f); |
| 937 EXPECT_FLOAT_EQ(9.f, | 906 EXPECT_FLOAT_EQ(9.f, |
| 938 curve->GetValue(base::TimeDelta::FromSecondsD(scale * 4.f))); | 907 curve->GetValue(base::TimeDelta::FromSecondsD(scale * 4.f))); |
| 939 EXPECT_FLOAT_EQ(9.f, | 908 EXPECT_FLOAT_EQ(9.f, |
| 940 curve->GetValue(base::TimeDelta::FromSecondsD(scale * 5.f))); | 909 curve->GetValue(base::TimeDelta::FromSecondsD(scale * 5.f))); |
| 941 } | 910 } |
| 942 | 911 |
| 943 } // namespace | 912 } // namespace |
| 944 } // namespace cc | 913 } // namespace cc |
| OLD | NEW |