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