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

Unified Diff: cc/CCActiveAnimationTest.cpp

Issue 10961036: Gracefully handle zero duration curves in CCActiveAnimation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/CCActiveAnimation.cpp ('k') | cc/test/CCAnimationTestCommon.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/CCActiveAnimationTest.cpp
diff --git a/cc/CCActiveAnimationTest.cpp b/cc/CCActiveAnimationTest.cpp
index ec589b4edbd72fdbc195a4532edd8c258394cf83..a29da0bbc68f8d74a61d0b7f2b85fd5a1f5d958c 100644
--- a/cc/CCActiveAnimationTest.cpp
+++ b/cc/CCActiveAnimationTest.cpp
@@ -16,13 +16,18 @@ using namespace cc;
namespace {
-PassOwnPtr<CCActiveAnimation> createActiveAnimation(int iterations)
+PassOwnPtr<CCActiveAnimation> createActiveAnimation(int iterations, double duration)
{
- OwnPtr<CCActiveAnimation> toReturn(CCActiveAnimation::create(adoptPtr(new FakeFloatAnimationCurve), 0, 1, CCActiveAnimation::Opacity));
+ OwnPtr<CCActiveAnimation> toReturn(CCActiveAnimation::create(adoptPtr(new FakeFloatAnimationCurve(duration)), 0, 1, CCActiveAnimation::Opacity));
toReturn->setIterations(iterations);
return toReturn.release();
}
+PassOwnPtr<CCActiveAnimation> createActiveAnimation(int iterations)
+{
+ return createActiveAnimation(iterations, 1);
+}
+
TEST(CCActiveAnimationTest, TrimTimeZeroIterations)
{
OwnPtr<CCActiveAnimation> anim(createActiveAnimation(0));
@@ -107,6 +112,15 @@ TEST(CCActiveAnimationTest, TrimTimeSuspendResume)
EXPECT_EQ(1, anim->trimTimeToCurrentIteration(1024.5));
}
+TEST(CCActiveAnimationTest, TrimTimeZeroDuration)
+{
+ OwnPtr<CCActiveAnimation> anim(createActiveAnimation(0, 0));
+ anim->setRunState(CCActiveAnimation::Running, 0);
+ EXPECT_EQ(0, anim->trimTimeToCurrentIteration(-1));
+ EXPECT_EQ(0, anim->trimTimeToCurrentIteration(0));
+ EXPECT_EQ(0, anim->trimTimeToCurrentIteration(1));
+}
+
TEST(CCActiveAnimationTest, IsFinishedAtZeroIterations)
{
OwnPtr<CCActiveAnimation> anim(createActiveAnimation(0));
« no previous file with comments | « cc/CCActiveAnimation.cpp ('k') | cc/test/CCAnimationTestCommon.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698