From 7dfacdb1c820f955cb3cd6032ff5fbc2dd7d9df5 Mon Sep 17 00:00:00 2001 From: Chet Haase Date: Mon, 11 Jul 2011 17:01:56 -0700 Subject: Fix Animator cancel() behavior Previously, calling cancel() on an Animator would cause onAnimationCancel events to be sent to all listeners. This was confusing for listeners that were keying off this event for performing other actions, when the original animator wasn't truly canceled (because it wasn't even running, or had already been canceled earlier). This change hinges listener notification on the animator actually running; no events are sent otherwise. Also added the first set of Animator tests to verify that this behavior is correct. Change-Id: I81ab56559b5c0343c8dc7880e1c8235f3020975b --- .../animation/ObjectAnimatorEventsTest.java | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 core/tests/coretests/src/android/animation/ObjectAnimatorEventsTest.java (limited to 'core/tests/coretests/src/android/animation/ObjectAnimatorEventsTest.java') diff --git a/core/tests/coretests/src/android/animation/ObjectAnimatorEventsTest.java b/core/tests/coretests/src/android/animation/ObjectAnimatorEventsTest.java new file mode 100644 index 0000000..606a939 --- /dev/null +++ b/core/tests/coretests/src/android/animation/ObjectAnimatorEventsTest.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package android.animation; + +import android.widget.Button; +import com.android.frameworks.coretests.R; + +/** + * Listener tests for ObjectAnimator. + */ +public class ObjectAnimatorEventsTest extends EventsTest { + + @Override + public void setUp() throws Exception { + final BasicAnimatorActivity activity = getActivity(); + Button button = (Button) activity.findViewById(R.id.animatingButton); + + mAnimator = ObjectAnimator.ofFloat(button, "translationX", 0, 100); + super.setUp(); + } + +} -- cgit v1.1