diff options
author | Chet Haase <chet@google.com> | 2012-04-17 13:18:14 -0700 |
---|---|---|
committer | Chet Haase <chet@google.com> | 2012-04-17 13:58:44 -0700 |
commit | 17cf42cb85c22b50ecfa8d21efc992f99d20fc45 (patch) | |
tree | d8ba7cef26d25a01aeab9adee69cf731cc367421 /core/tests | |
parent | df1423e28ccb867c323c7b821bb2af1b6481ac07 (diff) | |
download | frameworks_base-17cf42cb85c22b50ecfa8d21efc992f99d20fc45.zip frameworks_base-17cf42cb85c22b50ecfa8d21efc992f99d20fc45.tar.gz frameworks_base-17cf42cb85c22b50ecfa8d21efc992f99d20fc45.tar.bz2 |
Fix logic of animator start/cancel/end callbacks
The callbacks for animators in some corner cases were not being
called correctly. For example, startDelayed animators that were
started and then ended didn't send out the proper events.
This CL fixes that logic. Specifically:
- An animator that is end()'d will implicitly start() itself and then
assign an end value. This was already the case, but listeners were not
getting notified. Now this situation causes callbacks to listeners for
both the start and end events.
- startDelayed animators that are end()'d or cancel()'d prior to finishing
the startDelay phase will send out events (start and cancel/end, as appropriate)
to listeners.
Change-Id: I40a0f2fdb19d9ec7c3726a91363686c6ecb7d915
Diffstat (limited to 'core/tests')
-rw-r--r-- | core/tests/coretests/src/android/animation/EventsTest.java | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/core/tests/coretests/src/android/animation/EventsTest.java b/core/tests/coretests/src/android/animation/EventsTest.java index 701a3f0..8df711b 100644 --- a/core/tests/coretests/src/android/animation/EventsTest.java +++ b/core/tests/coretests/src/android/animation/EventsTest.java @@ -173,8 +173,7 @@ public abstract class EventsTest // This should only be called on an animation that has been started and not // yet canceled or ended assertFalse(mCanceled); - assertTrue(mRunning); - assertTrue(mStarted); + assertTrue(mRunning || mStarted); mCanceled = true; } @@ -182,8 +181,7 @@ public abstract class EventsTest public void onAnimationEnd(Animator animation) { // This should only be called on an animation that has been started and not // yet ended - assertTrue(mRunning); - assertTrue(mStarted); + assertTrue(mRunning || mStarted); mRunning = false; mStarted = false; super.onAnimationEnd(animation); @@ -210,11 +208,12 @@ public abstract class EventsTest } /** - * Verify that calling end on an unstarted animator does nothing. + * Verify that calling end on an unstarted animator starts/ends an animator. */ @UiThreadTest @SmallTest public void testEnd() throws Exception { + mRunning = true; // end() implicitly starts an unstarted animator mAnimator.end(); } @@ -496,6 +495,7 @@ public abstract class EventsTest mRunning = true; mAnimator.start(); mAnimator.end(); + mRunning = true; // end() implicitly starts an unstarted animator mAnimator.end(); mFuture.release(); } catch (junit.framework.AssertionFailedError e) { @@ -544,6 +544,7 @@ public abstract class EventsTest mRunning = true; mAnimator.start(); mAnimator.end(); + mRunning = true; // end() implicitly starts an unstarted animator mAnimator.end(); mFuture.release(); } catch (junit.framework.AssertionFailedError e) { |