diff options
author | vollick@chromium.org <vollick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-21 22:08:47 +0000 |
---|---|---|
committer | vollick@chromium.org <vollick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-21 22:08:47 +0000 |
commit | 4dad47e1ae4b15f0bf1eb7272c2583526d305d7e (patch) | |
tree | f1ab3a26c0d627374ee17e7aa303a231d8b96bf8 /cc/CCActiveAnimationTest.cpp | |
parent | 0b1167d1d4ff375f35ec2fca03ecea3da3115d9b (diff) | |
download | chromium_src-4dad47e1ae4b15f0bf1eb7272c2583526d305d7e.zip chromium_src-4dad47e1ae4b15f0bf1eb7272c2583526d305d7e.tar.gz chromium_src-4dad47e1ae4b15f0bf1eb7272c2583526d305d7e.tar.bz2 |
Gracefully handle zero duration curves in CCActiveAnimation
We should trim to time 0 in this case.
BUG=
Review URL: https://chromiumcodereview.appspot.com/10961036
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@158092 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/CCActiveAnimationTest.cpp')
-rw-r--r-- | cc/CCActiveAnimationTest.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/cc/CCActiveAnimationTest.cpp b/cc/CCActiveAnimationTest.cpp index ec589b4..a29da0b 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)); |