1/* 2* Copyright (C) 2014 The Android Open Source Project 3* 4* Licensed under the Apache License, Version 2.0 (the "License"); 5* you may not use this file except in compliance with the License. 6* You may obtain a copy of the License at 7* 8* http://www.apache.org/licenses/LICENSE-2.0 9* 10* Unless required by applicable law or agreed to in writing, software 11* distributed under the License is distributed on an "AS IS" BASIS, 12* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13* See the License for the specific language governing permissions and 14* limitations under the License. 15*/ 16package android.animation; 17 18import android.test.ActivityInstrumentationTestCase2; 19 20import java.util.HashSet; 21import java.util.Set; 22import java.util.concurrent.CountDownLatch; 23import java.util.concurrent.TimeUnit; 24 25import com.android.frameworks.coretests.R; 26 27public class AnimatorInflaterTest extends ActivityInstrumentationTestCase2<BasicAnimatorActivity> { 28 Set<Integer> identityHashes = new HashSet<Integer>(); 29 30 public AnimatorInflaterTest() { 31 super(BasicAnimatorActivity.class); 32 } 33 34 private void assertUnique(Object object) { 35 assertUnique(object, ""); 36 } 37 38 private void assertUnique(Object object, String msg) { 39 final int code = System.identityHashCode(object); 40 assertTrue("object should be unique " + msg + ", obj:" + object, identityHashes.add(code)); 41 42 } 43 44 public void testLoadStateListAnimator() { 45 StateListAnimator sla1 = AnimatorInflater.loadStateListAnimator(getActivity(), 46 R.anim.test_state_anim); 47 sla1.setTarget(getActivity().mAnimatingButton); 48 StateListAnimator sla2 = AnimatorInflater.loadStateListAnimator(getActivity(), 49 R.anim.test_state_anim); 50 assertNull(sla2.getTarget()); 51 for (StateListAnimator sla : new StateListAnimator[]{sla1, sla2}) { 52 assertUnique(sla); 53 assertEquals(3, sla.getTuples().size()); 54 for (StateListAnimator.Tuple tuple : sla.getTuples()) { 55 assertUnique(tuple); 56 assertUnique(tuple.getAnimator()); 57 } 58 } 59 } 60 61} 62