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 */ 16 17 import static android.support.test.espresso.Espresso.onView; 18 import static android.support.test.espresso.action.ViewActions.click; 19 import static android.support.test.espresso.action.ViewActions.scrollTo; 20 import static android.support.test.espresso.assertion.ViewAssertions.matches; 21 import static android.support.test.espresso.matcher.ViewMatchers.withId; 22 import static android.support.test.espresso.matcher.ViewMatchers.withText; 23 24 import android.support.test.rule.ActivityTestRule; 25 import android.support.test.runner.AndroidJUnit4; 26 27 import androidx.test.filters.LargeTest; 28 29 import com.android.multiwindowplayground.MainActivity; 30 import com.android.multiwindowplayground.R; 31 32 import org.junit.Rule; 33 import org.junit.Test; 34 import org.junit.runner.RunWith; 35 36 @LargeTest 37 @RunWith(AndroidJUnit4.class) 38 public class LaunchTests { 39 40 @Rule 41 public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>( 42 MainActivity.class); 43 44 45 @Test testLaunchBasicActivity()46 public void testLaunchBasicActivity() { 47 // Click the 'start basic activity' button. 48 onView(withId(R.id.button_start_basic)).perform(scrollTo(), click()); 49 50 // Verify that the description for the basic activity is now displayed. 51 onView(withId(R.id.description)) 52 .check(matches(withText(R.string.activity_description_basic))); 53 } 54 55 @Test testLaunchUnresizableActivity()56 public void testLaunchUnresizableActivity() { 57 // Click the 'start unresizable activity' button. 58 onView(withId(R.id.start_unresizable)).perform(scrollTo(), click()); 59 60 // Verify that the description for the unresizable activity is now displayed. 61 onView(withId(R.id.description)) 62 .check(matches(withText(R.string.activity_description_unresizable))); 63 } 64 65 @Test testLaunchAdjacentActivity()66 public void testLaunchAdjacentActivity() { 67 68 // Click the 'start adjacent activity' button. 69 onView(withId(R.id.start_adjacent)).perform(scrollTo(), click()); 70 71 // Verify that the correct description is now displayed. 72 onView(withId(R.id.description)) 73 .check(matches(withText(R.string.activity_adjacent_description))); 74 } 75 76 @Test testLaunchCustomConfigurationActivity()77 public void testLaunchCustomConfigurationActivity() { 78 // Click the 'start activity that handles configuration changes' button. 79 onView(withId(R.id.start_customconfiguration)).perform(scrollTo(), click()); 80 81 // Verify that the correct description is now displayed. 82 onView(withId(R.id.description)) 83 .check(matches(withText(R.string.activity_custom_description))); 84 } 85 86 87 @Test testLaunchMinimumSizeActivity()88 public void testLaunchMinimumSizeActivity() { 89 // Click the 'start activity with minimum size' button. 90 onView(withId(R.id.start_minimumsize)).perform(scrollTo(), click()); 91 92 // Verify that the correct description is now displayed. 93 onView(withId(R.id.description)) 94 .check(matches(withText(R.string.activity_minimum_description))); 95 } 96 97 @Test testLaunchBoundsActivity()98 public void testLaunchBoundsActivity() { 99 // Click the 'start activity with launch bounds' button. 100 onView(withId(R.id.start_launchbounds)).perform(scrollTo(), click()); 101 102 // Verify that the correct description is now displayed. 103 onView(withId(R.id.description)) 104 .check(matches(withText(R.string.activity_bounds_description))); 105 } 106 107 108 } 109