1/* 2 * Copyright (C) 2016 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.support.v4.app; 17 18import static junit.framework.Assert.assertEquals; 19 20import static org.junit.Assert.assertNull; 21 22import android.support.test.filters.SmallTest; 23import android.support.test.runner.AndroidJUnit4; 24import android.support.v4.BaseInstrumentationTestCase; 25 26import org.junit.Before; 27import org.junit.Test; 28import org.junit.runner.RunWith; 29 30@RunWith(AndroidJUnit4.class) 31@SmallTest 32public class SupportActivityTest extends BaseInstrumentationTestCase<TestSupportActivity> { 33 private SupportActivity mSupportActivity; 34 private TestExtraData mTestExtraData; 35 36 public SupportActivityTest() { 37 super(TestSupportActivity.class); 38 } 39 40 @Before 41 public void setUp() { 42 mSupportActivity = mActivityTestRule.getActivity(); 43 mTestExtraData = new TestExtraData(); 44 mSupportActivity.putExtraData(mTestExtraData); 45 } 46 47 @Test 48 public void testGetExtraData_returnsNullForNotAdded() { 49 assertNull(mSupportActivity.getExtraData(NeverAddedExtraData.class)); 50 } 51 52 @Test 53 public void testGetExtraData() { 54 assertEquals(mTestExtraData, mSupportActivity.getExtraData(TestExtraData.class)); 55 } 56 57 public class NeverAddedExtraData extends SupportActivity.ExtraData { 58 } 59 60 public class TestExtraData extends SupportActivity.ExtraData { 61 } 62} 63 64