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 android.app.Activity; 20 import android.test.ActivityInstrumentationTestCase; 21 import android.test.UiThreadTest; 22 import android.test.suitebuilder.annotation.MediumTest; 23 24 import com.android.frameworks.coretests.R; 25 26 import static org.junit.Assert.assertFalse; 27 28 /** 29 * Exercise set View's transient state 30 */ 31 public class ViewTransientStateTest extends ActivityInstrumentationTestCase<ViewTransientState> { 32 33 View mP1; 34 View mP2; 35 View mP3; 36 37 public ViewTransientStateTest() { 38 super("com.android.frameworks.coretests", ViewTransientState.class); 39 } 40 41 @Override 42 public void setUp() throws Exception { 43 super.setUp(); 44 45 final Activity a = getActivity(); 46 mP1 = a.findViewById(R.id.p1); 47 mP2 = a.findViewById(R.id.p2); 48 mP3 = a.findViewById(R.id.p3); 49 } 50 51 @UiThreadTest 52 @MediumTest 53 public void testSetTransientState1() throws Exception { 54 mP3.setHasTransientState(true); 55 mP2.setHasTransientState(true); 56 mP3.setHasTransientState(false); 57 mP2.setHasTransientState(false); 58 assertFalse(mP3.hasTransientState()); 59 assertFalse(mP2.hasTransientState()); 60 assertFalse(mP1.hasTransientState()); 61 } 62 63 @UiThreadTest 64 @MediumTest 65 public void testSetTransientState2() throws Exception { 66 mP3.setHasTransientState(true); 67 mP2.setHasTransientState(true); 68 mP2.setHasTransientState(false); 69 mP3.setHasTransientState(false); 70 assertFalse(mP3.hasTransientState()); 71 assertFalse(mP2.hasTransientState()); 72 assertFalse(mP1.hasTransientState()); 73 } 74 75 @UiThreadTest 76 @MediumTest 77 public void testSetTransientState3() throws Exception { 78 mP2.setHasTransientState(true); 79 mP3.setHasTransientState(true); 80 mP3.setHasTransientState(false); 81 mP2.setHasTransientState(false); 82 assertFalse(mP3.hasTransientState()); 83 assertFalse(mP2.hasTransientState()); 84 assertFalse(mP1.hasTransientState()); 85 } 86 87 @UiThreadTest 88 @MediumTest 89 public void testSetTransientState4() throws Exception { 90 mP2.setHasTransientState(true); 91 mP3.setHasTransientState(true); 92 mP2.setHasTransientState(false); 93 mP3.setHasTransientState(false); 94 assertFalse(mP3.hasTransientState()); 95 assertFalse(mP2.hasTransientState()); 96 assertFalse(mP1.hasTransientState()); 97 } 98 } 99