1 /* 2 * Copyright (C) 2017 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 */ 16 17 package android.view; 18 19 import static org.junit.Assert.assertNotNull; 20 import static org.junit.Assert.assertNull; 21 22 import android.app.Activity; 23 import android.content.Context; 24 import android.support.test.InstrumentationRegistry; 25 import android.support.test.annotation.UiThreadTest; 26 import android.support.test.filters.MediumTest; 27 import android.support.test.rule.ActivityTestRule; 28 29 import org.junit.Rule; 30 import org.junit.Test; 31 32 @MediumTest 33 public class RenderNodeAnimatorTest { 34 @Rule 35 public ActivityTestRule<Activity> mActivityRule = new ActivityTestRule<>(Activity.class); 36 37 private Context getContext() { 38 return InstrumentationRegistry.getTargetContext(); 39 } 40 41 private Activity getActivity() { 42 return mActivityRule.getActivity(); 43 } 44 45 @UiThreadTest 46 @Test 47 public void testAlphaTransformationInfo() throws Throwable { 48 View view = new View(getContext()); 49 50 // attach the view, since otherwise the RenderNodeAnimator won't accept view as target 51 getActivity().setContentView(view); 52 53 RenderNodeAnimator anim = new RenderNodeAnimator(RenderNodeAnimator.ALPHA, 0.5f); 54 anim.setTarget(view); 55 assertNull(view.mTransformationInfo); 56 anim.start(); // should initialize mTransformationInfo 57 assertNotNull(view.mTransformationInfo); 58 } 59 } 60