diff options
author | Leon Scroggins III <scroggo@google.com> | 2018-01-21 15:50:12 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-01-22 19:32:17 +0000 |
commit | 2cb6cb1f338e655f63fa258efeaa38988ec6a7b3 (patch) | |
tree | 127b8829c7acd55ec1d70676dc15ac6880d5af73 /tests/AnimatedImageTest.cpp | |
parent | 0848fb0b3e3f465ec0de01ed7e0028cda32aa948 (diff) |
Add SkAnimatedImage::isFinished
Bug: b/63908092
Allows Android to know when to call onAnimationEnd.
Change-Id: I9cc102fb485e944ad5983eed9f0b941153128e88
Reviewed-on: https://skia-review.googlesource.com/97401
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
Diffstat (limited to 'tests/AnimatedImageTest.cpp')
-rw-r--r-- | tests/AnimatedImageTest.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/AnimatedImageTest.cpp b/tests/AnimatedImageTest.cpp index c8113d3fb1..584a69c383 100644 --- a/tests/AnimatedImageTest.cpp +++ b/tests/AnimatedImageTest.cpp @@ -132,8 +132,10 @@ DEF_TEST(AnimatedImage, r) { if (i == frameInfos.size() - 1 && defaultRepetitionCount == 0) { REPORTER_ASSERT(r, next == std::numeric_limits<double>::max()); REPORTER_ASSERT(r, !animatedImage->isRunning()); + REPORTER_ASSERT(r, animatedImage->isFinished()); } else { REPORTER_ASSERT(r, animatedImage->isRunning()); + REPORTER_ASSERT(r, !animatedImage->isFinished()); double expectedNext = currentTime + frameInfos[i].fDuration; if (next != expectedNext) { ERRORF(r, "Time did not match for frame %i: next: %g expected: %g", @@ -182,6 +184,7 @@ DEF_TEST(AnimatedImage, r) { double interval = next - currentTime; animatedImage->stop(); REPORTER_ASSERT(r, !animatedImage->isRunning()); + REPORTER_ASSERT(r, !animatedImage->isFinished()); currentTime = next; double stoppedNext = animatedImage->update(currentTime); @@ -201,6 +204,7 @@ DEF_TEST(AnimatedImage, r) { } REPORTER_ASSERT(r, animatedImage->isRunning()); + REPORTER_ASSERT(r, !animatedImage->isFinished()); animatedImage->reset(); if (!testDraw(animatedImage, 0)) { ERRORF(r, "reset failed"); @@ -214,6 +218,7 @@ DEF_TEST(AnimatedImage, r) { animatedImage->setRepetitionCount(loopCount); for (int loops = 0; loops <= loopCount; loops++) { REPORTER_ASSERT(r, animatedImage->isRunning()); + REPORTER_ASSERT(r, !animatedImage->isFinished()); for (size_t i = 0; i < frameInfos.size(); ++i) { double next = animatedImage->update(currentTime); if (animatedImage->isRunning()) { @@ -224,6 +229,11 @@ DEF_TEST(AnimatedImage, r) { if (animatedImage->isRunning()) { ERRORF(r, "%s animation still running after %i loops", file, loopCount); } + + if (!animatedImage->isFinished()) { + ERRORF(r, "%s animation should have finished with specified loop count (%i)", + file, loopCount); + } } } } |