3efd037e63
Bug: 78589564 $ adb shell am instrument -w com.android.launcher3.tests/android.support.test.runner.AndroidJUnitRunner com.android.launcher3.allapps.search.DefaultAppSearchAlgorithmTest:.. com.android.launcher3.logging.FileLogTest:.. com.android.launcher3.model.AddWorkspaceItemsTaskTest:.... com.android.launcher3.model.CacheDataUpdatedTaskTest:... com.android.launcher3.model.DbDowngradeHelperTest:.... com.android.launcher3.model.GridSizeMigrationTaskTest:........... com.android.launcher3.model.LoaderCursorTest:........ com.android.launcher3.model.PackageInstallStateChangedTaskTest:... com.android.launcher3.popup.PopupPopulatorTest:.. com.android.launcher3.provider.RestoreDbTaskTest:.. com.android.launcher3.touch.SwipeDetectorTest:..... com.android.launcher3.ui.AllAppsAppLaunchTest:.. com.android.launcher3.ui.AllAppsIconToHomeTest:.. com.android.launcher3.ui.ShortcutsLaunchTest:.. com.android.launcher3.ui.ShortcutsToHomeTest:.. com.android.launcher3.ui.WorkTabTest:. com.android.launcher3.ui.widget.AddConfigWidgetTest:.... com.android.launcher3.ui.widget.AddWidgetTest:.. com.android.launcher3.ui.widget.BindWidgetTest:...... com.android.launcher3.ui.widget.RequestPinItemTest:. com.android.launcher3.util.GridOccupancyTest:.. com.android.launcher3.widget.WidgetsListAdapterTest:...... Time: 180.363 OK (76 test) Change-Id: I4a50581bc8d06a030467ac9fec3e1ef668745214
82 lines
3.0 KiB
Java
82 lines
3.0 KiB
Java
package com.android.launcher3.ui;
|
|
|
|
import android.content.pm.LauncherActivityInfo;
|
|
import android.graphics.Point;
|
|
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.view.MotionEvent;
|
|
|
|
import com.android.launcher3.R;
|
|
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
|
|
@RunWith(AndroidJUnit4.class)
|
|
public class ShortcutsToHomeTest extends AbstractLauncherUiTest {
|
|
|
|
@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 {
|
|
clearHomescreen();
|
|
mActivityMonitor.startLauncher();
|
|
|
|
LauncherActivityInfo testApp = 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(testApp.getLabel().toString()));
|
|
// Press icon center until shortcuts appear
|
|
Point iconCenter = icon.getVisibleCenter();
|
|
sendPointer(MotionEvent.ACTION_DOWN, iconCenter);
|
|
UiObject2 deepShortcutsContainer = findViewById(R.id.deep_shortcuts_container);
|
|
assertNotNull(deepShortcutsContainer);
|
|
sendPointer(MotionEvent.ACTION_UP, iconCenter);
|
|
|
|
// Drag the first shortcut to the home screen.
|
|
assertTrue(deepShortcutsContainer.getChildCount() > 0);
|
|
UiObject2 shortcut = deepShortcutsContainer.getChildren().get(1)
|
|
.findObject(getSelectorForId(R.id.bubble_text));
|
|
String shortcutName = shortcut.getText();
|
|
dragToWorkspace(shortcut, false);
|
|
|
|
// Verify that the shortcut works on home screen
|
|
// (the app opens and has the same text as the shortcut).
|
|
mDevice.findObject(By.text(shortcutName)).click();
|
|
assertTrue(mDevice.wait(Until.hasObject(By.pkg(
|
|
testApp.getComponentName().getPackageName())
|
|
.text(shortcutName)), DEFAULT_UI_TIMEOUT));
|
|
}
|
|
}
|