summaryrefslogtreecommitdiffstats
path: root/tests/src/com/android/launcher3/ui/ShortcutsToHomeTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'tests/src/com/android/launcher3/ui/ShortcutsToHomeTest.java')
-rw-r--r--tests/src/com/android/launcher3/ui/ShortcutsToHomeTest.java39
1 files changed, 22 insertions, 17 deletions
diff --git a/tests/src/com/android/launcher3/ui/ShortcutsToHomeTest.java b/tests/src/com/android/launcher3/ui/ShortcutsToHomeTest.java
index 5d86d1ec6..434311dd6 100644
--- a/tests/src/com/android/launcher3/ui/ShortcutsToHomeTest.java
+++ b/tests/src/com/android/launcher3/ui/ShortcutsToHomeTest.java
@@ -2,40 +2,43 @@ package com.android.launcher3.ui;
import android.content.pm.LauncherActivityInfo;
import android.graphics.Point;
-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 android.view.MotionEvent;
import com.android.launcher3.R;
-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.assertNotNull;
+import static org.junit.Assert.assertTrue;
/**
* Test for dragging a deep shortcut to the home screen.
*/
@LargeTest
-public class ShortcutsToHomeTest extends LauncherInstrumentationTestCase {
-
- private LauncherActivityInfo mSettingsApp;
+@RunWith(AndroidJUnit4.class)
+public class ShortcutsToHomeTest 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();
@@ -43,14 +46,16 @@ public class ShortcutsToHomeTest extends LauncherInstrumentationTestCase {
private void performTest() throws Throwable {
clearHomescreen();
- startLauncher();
+ mActivityMonitor.startLauncher();
+
+ LauncherActivityInfo settingsApp = getSettingsApp();
// Open all apps and wait for load complete.
final UiObject2 appsContainer = openAllApps();
assertTrue(Wait.atMost(Condition.minChildCount(appsContainer, 2), DEFAULT_UI_TIMEOUT));
// Find the app and long press it to show shortcuts.
- UiObject2 icon = scrollAndFind(appsContainer, By.text(mSettingsApp.getLabel().toString()));
+ UiObject2 icon = scrollAndFind(appsContainer, By.text(settingsApp.getLabel().toString()));
// Press icon center until shortcuts appear
Point iconCenter = icon.getVisibleCenter();
sendPointer(MotionEvent.ACTION_DOWN, iconCenter);
@@ -69,7 +74,7 @@ public class ShortcutsToHomeTest extends LauncherInstrumentationTestCase {
// (the app opens and has the same text as the shortcut).
mDevice.findObject(By.text(shortcutName)).click();
assertTrue(mDevice.wait(Until.hasObject(By.pkg(
- mSettingsApp.getComponentName().getPackageName())
+ settingsApp.getComponentName().getPackageName())
.text(shortcutName)), DEFAULT_UI_TIMEOUT));
}
}