From 2cb6cb1f338e655f63fa258efeaa38988ec6a7b3 Mon Sep 17 00:00:00 2001 From: Leon Scroggins III Date: Sun, 21 Jan 2018 15:50:12 -0500 Subject: 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 Commit-Queue: Leon Scroggins --- tests/AnimatedImageTest.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tests/AnimatedImageTest.cpp') 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::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); + } } } } -- cgit v1.2.3