Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(477)

Side by Side Diff: cc/animation/keyframed_animation_curve_unittest.cc

Issue 642983003: cc: Make PictureLayerImpl use a better choice for animated raster scale. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: animationscale: fixtest Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/animation/keyframed_animation_curve.cc ('k') | cc/animation/layer_animation_controller.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 EXPECT_FALSE(curve->IsTranslation()); 503 EXPECT_FALSE(curve->IsTranslation());
504 504
505 TransformOperations operations4; 505 TransformOperations operations4;
506 operations3.AppendTranslate(2.f, 2.f, 2.f); 506 operations3.AppendTranslate(2.f, 2.f, 2.f);
507 curve->AddKeyframe(TransformKeyframe::Create( 507 curve->AddKeyframe(TransformKeyframe::Create(
508 3.0, operations4, scoped_ptr<TimingFunction>())); 508 3.0, operations4, scoped_ptr<TimingFunction>()));
509 509
510 EXPECT_FALSE(curve->IsTranslation()); 510 EXPECT_FALSE(curve->IsTranslation());
511 } 511 }
512 512
513 // Tests that maximum scale is computed as expected. 513 // Tests that maximum target scale is computed as expected.
514 TEST(KeyframedAnimationCurveTest, MaximumScale) { 514 TEST(KeyframedAnimationCurveTest, MaximumTargetScale) {
515 scoped_ptr<KeyframedTransformAnimationCurve> curve( 515 scoped_ptr<KeyframedTransformAnimationCurve> curve(
516 KeyframedTransformAnimationCurve::Create()); 516 KeyframedTransformAnimationCurve::Create());
517 517
518 TransformOperations operations1; 518 TransformOperations operations1;
519 curve->AddKeyframe(TransformKeyframe::Create( 519 curve->AddKeyframe(TransformKeyframe::Create(
520 0.0, operations1, scoped_ptr<TimingFunction>())); 520 0.0, operations1, scoped_ptr<TimingFunction>()));
521 operations1.AppendScale(2.f, -3.f, 1.f); 521 operations1.AppendScale(2.f, -3.f, 1.f);
522 curve->AddKeyframe(TransformKeyframe::Create( 522 curve->AddKeyframe(TransformKeyframe::Create(
523 1.0, operations1, EaseTimingFunction::Create())); 523 1.0, operations1, EaseTimingFunction::Create()));
524 524
525 float maximum_scale = 0.f; 525 float maximum_scale = 0.f;
526 EXPECT_TRUE(curve->MaximumScale(&maximum_scale)); 526 EXPECT_TRUE(curve->MaximumTargetScale(true, &maximum_scale));
527 EXPECT_EQ(3.f, maximum_scale); 527 EXPECT_EQ(3.f, maximum_scale);
528 528
529 TransformOperations operations2; 529 TransformOperations operations2;
530 operations2.AppendScale(6.f, 3.f, 2.f); 530 operations2.AppendScale(6.f, 3.f, 2.f);
531 curve->AddKeyframe(TransformKeyframe::Create( 531 curve->AddKeyframe(TransformKeyframe::Create(
532 2.0, operations2, EaseTimingFunction::Create())); 532 2.0, operations2, EaseTimingFunction::Create()));
533 533
534 EXPECT_TRUE(curve->MaximumScale(&maximum_scale)); 534 EXPECT_TRUE(curve->MaximumTargetScale(true, &maximum_scale));
535 EXPECT_EQ(6.f, maximum_scale); 535 EXPECT_EQ(6.f, maximum_scale);
536 536
537 TransformOperations operations3; 537 TransformOperations operations3;
538 operations3.AppendRotate(1.f, 0.f, 0.f, 90.f); 538 operations3.AppendRotate(1.f, 0.f, 0.f, 90.f);
539 curve->AddKeyframe(TransformKeyframe::Create( 539 curve->AddKeyframe(TransformKeyframe::Create(
540 3.0, operations3, EaseTimingFunction::Create())); 540 3.0, operations3, EaseTimingFunction::Create()));
541 541
542 EXPECT_FALSE(curve->MaximumScale(&maximum_scale)); 542 EXPECT_FALSE(curve->MaximumTargetScale(true, &maximum_scale));
543
544 // The original scale is not used in computing the max.
545 scoped_ptr<KeyframedTransformAnimationCurve> curve2(
546 KeyframedTransformAnimationCurve::Create());
547
548 TransformOperations operations4;
549 operations4.AppendScale(0.4f, 0.2f, 0.6f);
550 curve2->AddKeyframe(TransformKeyframe::Create(
551 0.0, operations4, EaseTimingFunction::Create()));
552 TransformOperations operations5;
553 operations5.AppendScale(0.5f, 0.3f, -0.8f);
554 curve2->AddKeyframe(TransformKeyframe::Create(
555 1.0, operations5, EaseTimingFunction::Create()));
556
557 EXPECT_TRUE(curve2->MaximumTargetScale(true, &maximum_scale));
558 EXPECT_EQ(0.8f, maximum_scale);
559
560 EXPECT_TRUE(curve2->MaximumTargetScale(false, &maximum_scale));
561 EXPECT_EQ(0.6f, maximum_scale);
543 } 562 }
544 563
545 // Tests that an animation with a curve timing function works as expected. 564 // Tests that an animation with a curve timing function works as expected.
546 TEST(KeyframedAnimationCurveTest, CurveTiming) { 565 TEST(KeyframedAnimationCurveTest, CurveTiming) {
547 scoped_ptr<KeyframedFloatAnimationCurve> curve( 566 scoped_ptr<KeyframedFloatAnimationCurve> curve(
548 KeyframedFloatAnimationCurve::Create()); 567 KeyframedFloatAnimationCurve::Create());
549 curve->AddKeyframe( 568 curve->AddKeyframe(
550 FloatKeyframe::Create(0.0, 0.f, scoped_ptr<TimingFunction>())); 569 FloatKeyframe::Create(0.0, 0.f, scoped_ptr<TimingFunction>()));
551 curve->AddKeyframe( 570 curve->AddKeyframe(
552 FloatKeyframe::Create(1.0, 1.f, scoped_ptr<TimingFunction>())); 571 FloatKeyframe::Create(1.0, 1.f, scoped_ptr<TimingFunction>()));
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 FloatKeyframe::Create(4.0, 9.f, scoped_ptr<TimingFunction>())); 649 FloatKeyframe::Create(4.0, 9.f, scoped_ptr<TimingFunction>()));
631 // Curve timing function producing outputs outside of range [0,1]. 650 // Curve timing function producing outputs outside of range [0,1].
632 curve->SetTimingFunction( 651 curve->SetTimingFunction(
633 CubicBezierTimingFunction::Create(0.5f, -0.5f, 0.5f, 1.5f).Pass()); 652 CubicBezierTimingFunction::Create(0.5f, -0.5f, 0.5f, 1.5f).Pass());
634 EXPECT_LE(curve->GetValue(1.f), 0.f); // c(.25) < 0 653 EXPECT_LE(curve->GetValue(1.f), 0.f); // c(.25) < 0
635 EXPECT_GE(curve->GetValue(3.f), 9.f); // c(.75) > 1 654 EXPECT_GE(curve->GetValue(3.f), 9.f); // c(.75) > 1
636 } 655 }
637 656
638 } // namespace 657 } // namespace
639 } // namespace cc 658 } // namespace cc
OLDNEW
« no previous file with comments | « cc/animation/keyframed_animation_curve.cc ('k') | cc/animation/layer_animation_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698