1 package com.android.launcher3.ui; 2 3 import android.content.pm.LauncherActivityInfo; 4 import android.support.test.filters.LargeTest; 5 import android.support.test.runner.AndroidJUnit4; 6 import android.support.test.uiautomator.By; 7 import android.support.test.uiautomator.UiObject2; 8 import android.support.test.uiautomator.Until; 9 10 import com.android.launcher3.util.Condition; 11 import com.android.launcher3.util.Wait; 12 import com.android.launcher3.util.rule.LauncherActivityRule; 13 14 import org.junit.Rule; 15 import org.junit.Test; 16 import org.junit.runner.RunWith; 17 18 import static org.junit.Assert.assertTrue; 19 20 /** 21 * Test for verifying apps is launched from all-apps 22 */ 23 @LargeTest 24 @RunWith(AndroidJUnit4.class) 25 public class AllAppsAppLaunchTest extends AbstractLauncherUiTest { 26 27 @Rule public LauncherActivityRule mActivityMonitor = new LauncherActivityRule(); 28 29 @Test 30 public void testAppLauncher_portrait() throws Exception { 31 lockRotation(true); 32 performTest(); 33 } 34 35 @Test 36 public void testAppLauncher_landscape() throws Exception { 37 lockRotation(false); 38 performTest(); 39 } 40 41 private void performTest() throws Exception { 42 mActivityMonitor.startLauncher(); 43 44 LauncherActivityInfo settingsApp = getSettingsApp(); 45 46 // Open all apps and wait for load complete 47 final UiObject2 appsContainer = openAllApps(); 48 assertTrue(Wait.atMost(Condition.minChildCount(appsContainer, 2), DEFAULT_UI_TIMEOUT)); 49 50 // Open settings app and verify app launched 51 scrollAndFind(appsContainer, By.text(settingsApp.getLabel().toString())).click(); 52 assertTrue(mDevice.wait(Until.hasObject(By.pkg( 53 settingsApp.getComponentName().getPackageName()).depth(0)), DEFAULT_UI_TIMEOUT)); 54 } 55 } 56