• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package com.android.launcher3.ui;
2 
3 import android.content.pm.LauncherActivityInfo;
4 import android.os.Process;
5 import android.support.test.uiautomator.By;
6 import android.support.test.uiautomator.UiObject2;
7 import android.support.test.uiautomator.Until;
8 import android.test.suitebuilder.annotation.LargeTest;
9 
10 import com.android.launcher3.compat.LauncherAppsCompat;
11 import com.android.launcher3.util.Condition;
12 import com.android.launcher3.util.Wait;
13 
14 /**
15  * Test for verifying apps is launched from all-apps
16  */
17 @LargeTest
18 public class AllAppsAppLaunchTest extends LauncherInstrumentationTestCase {
19 
20     private LauncherActivityInfo mSettingsApp;
21 
22     @Override
setUp()23     protected void setUp() throws Exception {
24         super.setUp();
25 
26         mSettingsApp = LauncherAppsCompat.getInstance(mTargetContext)
27                 .getActivityList("com.android.settings", Process.myUserHandle()).get(0);
28     }
29 
testAppLauncher_portrait()30     public void testAppLauncher_portrait() throws Exception {
31         lockRotation(true);
32         performTest();
33     }
34 
testAppLauncher_landscape()35     public void testAppLauncher_landscape() throws Exception {
36         lockRotation(false);
37         performTest();
38     }
39 
performTest()40     private void performTest() throws Exception {
41         startLauncher();
42 
43         // Open all apps and wait for load complete
44         final UiObject2 appsContainer = openAllApps();
45         assertTrue(Wait.atMost(Condition.minChildCount(appsContainer, 2), DEFAULT_UI_TIMEOUT));
46 
47         // Open settings app and verify app launched
48         scrollAndFind(appsContainer, By.text(mSettingsApp.getLabel().toString())).click();
49         assertTrue(mDevice.wait(Until.hasObject(By.pkg(
50                 mSettingsApp.getComponentName().getPackageName()).depth(0)), DEFAULT_UI_TIMEOUT));
51     }
52 }
53