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

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

Issue 140253013: Define accelerated steps time function. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updated patch: remove question about velocity Created 6 years, 3 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 | « no previous file | cc/animation/timing_function.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 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 420
421 EXPECT_FLOAT_EQ(0.f, curve->GetValue(0.f)); 421 EXPECT_FLOAT_EQ(0.f, curve->GetValue(0.f));
422 EXPECT_LT(0.f, curve->GetValue(0.25f)); 422 EXPECT_LT(0.f, curve->GetValue(0.25f));
423 EXPECT_GT(0.25f, curve->GetValue(0.25f)); 423 EXPECT_GT(0.25f, curve->GetValue(0.25f));
424 EXPECT_NEAR(curve->GetValue(0.5f), 0.5f, 0.00015f); 424 EXPECT_NEAR(curve->GetValue(0.5f), 0.5f, 0.00015f);
425 EXPECT_LT(0.75f, curve->GetValue(0.75f)); 425 EXPECT_LT(0.75f, curve->GetValue(0.75f));
426 EXPECT_GT(1.f, curve->GetValue(0.75f)); 426 EXPECT_GT(1.f, curve->GetValue(0.75f));
427 EXPECT_FLOAT_EQ(1.f, curve->GetValue(1.f)); 427 EXPECT_FLOAT_EQ(1.f, curve->GetValue(1.f));
428 } 428 }
429 429
430 // Tests that a steps timing function works as expected.
431 TEST(KeyframedAnimationCurveTest, StepsTimingFunction) {
432 scoped_ptr<KeyframedFloatAnimationCurve> curve(
433 KeyframedFloatAnimationCurve::Create());
434 curve->AddKeyframe(FloatKeyframe::Create(
435 0.0,
436 0.f,
437 StepsTimingFunction::Create(36, false).PassAs<TimingFunction>()));
438 curve->AddKeyframe(
439 FloatKeyframe::Create(1.0, 1.f, scoped_ptr<TimingFunction>()));
440
441 EXPECT_FLOAT_EQ(0.f, curve->GetValue(0.f));
442 EXPECT_FLOAT_EQ(7.0 / 36.0, curve->GetValue(0.20f));
443 EXPECT_FLOAT_EQ(0.25f, curve->GetValue(0.25f));
444 EXPECT_FLOAT_EQ(10.0 / 36.0, curve->GetValue(0.30f));
445 EXPECT_FLOAT_EQ(0.5f, curve->GetValue(0.5f));
446 EXPECT_FLOAT_EQ(21.0 / 36.0, curve->GetValue(0.60f));
447 EXPECT_FLOAT_EQ(0.75f, curve->GetValue(0.75f));
448 EXPECT_FLOAT_EQ(32.0 / 36.0, curve->GetValue(0.90f));
449 EXPECT_FLOAT_EQ(1.f, curve->GetValue(1.f));
450 }
451
430 // Tests that animated bounds are computed as expected. 452 // Tests that animated bounds are computed as expected.
431 TEST(KeyframedAnimationCurveTest, AnimatedBounds) { 453 TEST(KeyframedAnimationCurveTest, AnimatedBounds) {
432 scoped_ptr<KeyframedTransformAnimationCurve> curve( 454 scoped_ptr<KeyframedTransformAnimationCurve> curve(
433 KeyframedTransformAnimationCurve::Create()); 455 KeyframedTransformAnimationCurve::Create());
434 456
435 TransformOperations operations1; 457 TransformOperations operations1;
436 curve->AddKeyframe(TransformKeyframe::Create( 458 curve->AddKeyframe(TransformKeyframe::Create(
437 0.0, operations1, scoped_ptr<TimingFunction>())); 459 0.0, operations1, scoped_ptr<TimingFunction>()));
438 operations1.AppendTranslate(2.0, 3.0, -1.0); 460 operations1.AppendTranslate(2.0, 3.0, -1.0);
439 curve->AddKeyframe(TransformKeyframe::Create( 461 curve->AddKeyframe(TransformKeyframe::Create(
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 TransformOperations operations3; 562 TransformOperations operations3;
541 operations3.AppendRotate(1.f, 0.f, 0.f, 90.f); 563 operations3.AppendRotate(1.f, 0.f, 0.f, 90.f);
542 curve->AddKeyframe(TransformKeyframe::Create( 564 curve->AddKeyframe(TransformKeyframe::Create(
543 3.0, operations3, EaseTimingFunction::Create())); 565 3.0, operations3, EaseTimingFunction::Create()));
544 566
545 EXPECT_FALSE(curve->MaximumScale(&maximum_scale)); 567 EXPECT_FALSE(curve->MaximumScale(&maximum_scale));
546 } 568 }
547 569
548 } // namespace 570 } // namespace
549 } // namespace cc 571 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/animation/timing_function.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698