diff options
Diffstat (limited to 'tests/src/com/android/launcher3/ui/AllAppsIconToHomeTest.java')
-rw-r--r-- | tests/src/com/android/launcher3/ui/AllAppsIconToHomeTest.java | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/tests/src/com/android/launcher3/ui/AllAppsIconToHomeTest.java b/tests/src/com/android/launcher3/ui/AllAppsIconToHomeTest.java index 936175087..00f30ada9 100644 --- a/tests/src/com/android/launcher3/ui/AllAppsIconToHomeTest.java +++ b/tests/src/com/android/launcher3/ui/AllAppsIconToHomeTest.java @@ -1,58 +1,62 @@ package com.android.launcher3.ui; import android.content.pm.LauncherActivityInfo; -import android.os.Process; +import android.support.test.filters.LargeTest; +import android.support.test.runner.AndroidJUnit4; import android.support.test.uiautomator.By; import android.support.test.uiautomator.UiObject2; import android.support.test.uiautomator.Until; -import android.test.suitebuilder.annotation.LargeTest; -import com.android.launcher3.compat.LauncherAppsCompat; import com.android.launcher3.util.Condition; import com.android.launcher3.util.Wait; +import com.android.launcher3.util.rule.LauncherActivityRule; +import com.android.launcher3.util.rule.ShellCommandRule; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.assertTrue; /** * Test for dragging an icon from all-apps to homescreen. */ @LargeTest -public class AllAppsIconToHomeTest extends LauncherInstrumentationTestCase { - - private LauncherActivityInfo mSettingsApp; +@RunWith(AndroidJUnit4.class) +public class AllAppsIconToHomeTest extends AbstractLauncherUiTest { - @Override - protected void setUp() throws Exception { - super.setUp(); - setDefaultLauncher(); - - mSettingsApp = LauncherAppsCompat.getInstance(mTargetContext) - .getActivityList("com.android.settings", Process.myUserHandle()).get(0); - } + @Rule public LauncherActivityRule mActivityMonitor = new LauncherActivityRule(); + @Rule public ShellCommandRule mDefaultLauncherRule = ShellCommandRule.setDefaultLauncher(); + @Test public void testDragIcon_portrait() throws Throwable { lockRotation(true); performTest(); } + @Test public void testDragIcon_landscape() throws Throwable { lockRotation(false); performTest(); } private void performTest() throws Throwable { + LauncherActivityInfo settingsApp = getSettingsApp(); + clearHomescreen(); - startLauncher(); + mActivityMonitor.startLauncher(); // Open all apps and wait for load complete. final UiObject2 appsContainer = openAllApps(); assertTrue(Wait.atMost(Condition.minChildCount(appsContainer, 2), DEFAULT_UI_TIMEOUT)); // Drag icon to homescreen. - UiObject2 icon = scrollAndFind(appsContainer, By.text(mSettingsApp.getLabel().toString())); + UiObject2 icon = scrollAndFind(appsContainer, By.text(settingsApp.getLabel().toString())); dragToWorkspace(icon, true); // Verify that the icon works on homescreen. - mDevice.findObject(By.text(mSettingsApp.getLabel().toString())).click(); + mDevice.findObject(By.text(settingsApp.getLabel().toString())).click(); assertTrue(mDevice.wait(Until.hasObject(By.pkg( - mSettingsApp.getComponentName().getPackageName()).depth(0)), DEFAULT_UI_TIMEOUT)); + settingsApp.getComponentName().getPackageName()).depth(0)), DEFAULT_UI_TIMEOUT)); } } |