Search in sources :

Example 31 with Launcher

use of com.android.launcher3.Launcher in project android_packages_apps_Launcher3 by crdroidandroid.

the class FallbackRecentsTest method testOverview.

// b/143488140
// @NavigationModeSwitch
@Test
public void testOverview() {
    startAppFast(getAppPackageName());
    startAppFast(resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR));
    startTestActivity(2);
    Wait.atMost("Expected three apps in the task list", () -> mLauncher.getRecentTasks().size() >= 3, DEFAULT_ACTIVITY_TIMEOUT, mLauncher);
    BaseOverview overview = mLauncher.getBackground().switchToOverview();
    executeOnRecents(recents -> {
        assertTrue("Don't have at least 3 tasks", getTaskCount(recents) >= 3);
    });
    // Test flinging forward and backward.
    overview.flingForward();
    final Integer currentTaskAfterFlingForward = getFromRecents(this::getCurrentOverviewPage);
    executeOnRecents(recents -> assertTrue("Current task in Overview is still 0", currentTaskAfterFlingForward > 0));
    overview.flingBackward();
    executeOnRecents(recents -> assertTrue("Flinging back in Overview did nothing", getCurrentOverviewPage(recents) < currentTaskAfterFlingForward));
    // Test opening a task.
    overview = pressHomeAndGoToOverview();
    OverviewTask task = overview.getCurrentTask();
    assertNotNull("overview.getCurrentTask() returned null (1)", task);
    assertNotNull("OverviewTask.open returned null", task.open());
    assertTrue("Test activity didn't open from Overview", TestHelpers.wait(Until.hasObject(By.pkg(getAppPackageName()).text("TestActivity2")), DEFAULT_UI_TIMEOUT));
    // Test dismissing a task.
    overview = pressHomeAndGoToOverview();
    final Integer numTasks = getFromRecents(this::getTaskCount);
    task = overview.getCurrentTask();
    assertNotNull("overview.getCurrentTask() returned null (2)", task);
    task.dismiss();
    executeOnRecents(recents -> assertEquals("Dismissing a task didn't remove 1 task from Overview", numTasks - 1, getTaskCount(recents)));
    // Test dismissing all tasks.
    pressHomeAndGoToOverview().dismissAllTasks();
    assertTrue("Fallback Launcher not visible", TestHelpers.wait(Until.hasObject(By.pkg(mOtherLauncherActivity.packageName)), WAIT_TIME_MS));
}
Also used : OverviewTask(com.android.launcher3.tapl.OverviewTask) BaseOverview(com.android.launcher3.tapl.BaseOverview) LargeTest(androidx.test.filters.LargeTest) Test(org.junit.Test)

Example 32 with Launcher

use of com.android.launcher3.Launcher in project android_packages_apps_Launcher3 by crdroidandroid.

the class NavigationModeSwitchRule method setActiveOverlay.

public static boolean setActiveOverlay(LauncherInstrumentation launcher, String overlayPackage, LauncherInstrumentation.NavigationModel expectedMode, Description description) throws Exception {
    if (!packageExists(overlayPackage)) {
        Log.d(TAG, "setActiveOverlay: " + overlayPackage + " pkg does not exist");
        return false;
    }
    Log.d(TAG, "setActiveOverlay: " + overlayPackage + "...");
    UiDevice.getInstance(getInstrumentation()).executeShellCommand("cmd overlay enable-exclusive --category " + overlayPackage);
    if (currentSysUiNavigationMode() != expectedMode) {
        final CountDownLatch latch = new CountDownLatch(1);
        final Context targetContext = getInstrumentation().getTargetContext();
        final SysUINavigationMode.NavigationModeChangeListener listener = newMode -> {
            if (LauncherInstrumentation.getNavigationModel(newMode.resValue) == expectedMode) {
                latch.countDown();
            }
        };
        targetContext.getMainExecutor().execute(() -> SYS_UI_NAVIGATION_MODE.addModeChangeListener(listener));
        // b/139137636
        // latch.await(60, TimeUnit.SECONDS);
        targetContext.getMainExecutor().execute(() -> SYS_UI_NAVIGATION_MODE.removeModeChangeListener(listener));
        Wait.atMost(() -> "Navigation mode didn't change to " + expectedMode, () -> currentSysUiNavigationMode() == expectedMode, WAIT_TIME_MS, launcher);
    // b/139137636
    // assertTrue(launcher, "Navigation mode didn't change to " + expectedMode,
    // currentSysUiNavigationMode() == expectedMode, description);
    }
    Wait.atMost("Couldn't switch to " + overlayPackage, () -> launcher.getNavigationModel() == expectedMode, WAIT_TIME_MS, launcher);
    Wait.atMost(() -> "Switching nav mode: " + launcher.getNavigationModeMismatchError(false), () -> launcher.getNavigationModeMismatchError(false) == null, WAIT_TIME_MS, launcher);
    AbstractLauncherUiTest.checkDetectedLeaks(launcher);
    return true;
}
Also used : Context(android.content.Context) Context(android.content.Context) FailureWatcher(com.android.launcher3.util.rule.FailureWatcher) Statement(org.junit.runners.model.Statement) ZERO_BUTTON(com.android.quickstep.NavigationModeSwitchRule.Mode.ZERO_BUTTON) NAV_BAR_MODE_3BUTTON_OVERLAY(com.android.systemui.shared.system.QuickStepContract.NAV_BAR_MODE_3BUTTON_OVERLAY) TWO_BUTTON(com.android.quickstep.NavigationModeSwitchRule.Mode.TWO_BUTTON) PackageManager(android.content.pm.PackageManager) TestRule(org.junit.rules.TestRule) QuickStepContract(com.android.systemui.shared.system.QuickStepContract) NAV_BAR_MODE_GESTURAL_OVERLAY(com.android.systemui.shared.system.QuickStepContract.NAV_BAR_MODE_GESTURAL_OVERLAY) By(androidx.test.uiautomator.By) TestHelpers(com.android.launcher3.tapl.TestHelpers) Retention(java.lang.annotation.Retention) InstrumentationRegistry.getInstrumentation(androidx.test.InstrumentationRegistry.getInstrumentation) THREE_BUTTON(com.android.quickstep.NavigationModeSwitchRule.Mode.THREE_BUTTON) AbstractLauncherUiTest(com.android.launcher3.ui.AbstractLauncherUiTest) ALL(com.android.quickstep.NavigationModeSwitchRule.Mode.ALL) Log(android.util.Log) UiDevice(androidx.test.uiautomator.UiDevice) LauncherInstrumentation(com.android.launcher3.tapl.LauncherInstrumentation) NAV_BAR_MODE_2BUTTON_OVERLAY(com.android.systemui.shared.system.QuickStepContract.NAV_BAR_MODE_2BUTTON_OVERLAY) Description(org.junit.runner.Description) Target(java.lang.annotation.Target) ElementType(java.lang.annotation.ElementType) CountDownLatch(java.util.concurrent.CountDownLatch) Wait(com.android.launcher3.util.Wait) RetentionPolicy(java.lang.annotation.RetentionPolicy) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 33 with Launcher

use of com.android.launcher3.Launcher in project android_packages_apps_Launcher3 by crdroidandroid.

the class StartLauncherViaGestureTests method runTest.

private void runTest(String... eventSequence) {
    final RaceConditionReproducer eventProcessor = new RaceConditionReproducer(eventSequence);
    // Destroy Launcher activity.
    closeLauncherActivity();
    // The test action.
    eventProcessor.startIteration();
    mLauncher.pressHome();
    eventProcessor.finishIteration();
}
Also used : RaceConditionReproducer(com.android.launcher3.util.RaceConditionReproducer)

Example 34 with Launcher

use of com.android.launcher3.Launcher in project android_packages_apps_Launcher3 by crdroidandroid.

the class TaplTestsQuickstep method testOverview.

@Test
@PortraitLandscape
public void testOverview() throws Exception {
    startTestAppsWithCheck();
    // mLauncher.pressHome() also tests an important case of pressing home while in background.
    Overview overview = mLauncher.pressHome().switchToOverview();
    assertTrue("Launcher internal state didn't switch to Overview", isInState(() -> LauncherState.OVERVIEW));
    executeOnLauncher(launcher -> assertTrue("Don't have at least 3 tasks", getTaskCount(launcher) >= 3));
    // Test flinging forward and backward.
    executeOnLauncher(launcher -> assertEquals("Current task in Overview is not 0", 0, getCurrentOverviewPage(launcher)));
    overview.flingForward();
    assertTrue("Launcher internal state is not Overview", isInState(() -> LauncherState.OVERVIEW));
    final Integer currentTaskAfterFlingForward = getFromLauncher(launcher -> getCurrentOverviewPage(launcher));
    executeOnLauncher(launcher -> assertTrue("Current task in Overview is still 0", currentTaskAfterFlingForward > 0));
    overview.flingBackward();
    assertTrue("Launcher internal state is not Overview", isInState(() -> LauncherState.OVERVIEW));
    executeOnLauncher(launcher -> assertTrue("Flinging back in Overview did nothing", getCurrentOverviewPage(launcher) < currentTaskAfterFlingForward));
    // Test opening a task.
    OverviewTask task = mLauncher.pressHome().switchToOverview().getCurrentTask();
    assertNotNull("overview.getCurrentTask() returned null (1)", task);
    assertNotNull("OverviewTask.open returned null", task.open());
    assertTrue("Test activity didn't open from Overview", mDevice.wait(Until.hasObject(By.pkg(getAppPackageName()).text("TestActivity2")), DEFAULT_UI_TIMEOUT));
    executeOnLauncher(launcher -> assertTrue("Launcher activity is the top activity; expecting another activity to be the top " + "one", isInBackground(launcher)));
    // Test dismissing a task.
    overview = mLauncher.pressHome().switchToOverview();
    assertTrue("Launcher internal state didn't switch to Overview", isInState(() -> LauncherState.OVERVIEW));
    final Integer numTasks = getFromLauncher(launcher -> getTaskCount(launcher));
    task = overview.getCurrentTask();
    assertNotNull("overview.getCurrentTask() returned null (2)", task);
    task.dismiss();
    executeOnLauncher(launcher -> assertEquals("Dismissing a task didn't remove 1 task from Overview", numTasks - 1, getTaskCount(launcher)));
    // Test UIDevice.pressHome, once we are in AllApps.
    mDevice.pressHome();
    waitForState("Launcher internal state didn't switch to Home", () -> LauncherState.NORMAL);
    // Test dismissing all tasks.
    mLauncher.getWorkspace().switchToOverview().dismissAllTasks();
    waitForState("Launcher internal state didn't switch to Home", () -> LauncherState.NORMAL);
    executeOnLauncher(launcher -> assertEquals("Still have tasks after dismissing all", 0, getTaskCount(launcher)));
}
Also used : OverviewTask(com.android.launcher3.tapl.OverviewTask) Overview(com.android.launcher3.tapl.Overview) LargeTest(androidx.test.filters.LargeTest) Test(org.junit.Test)

Example 35 with Launcher

use of com.android.launcher3.Launcher in project android_packages_apps_Launcher3 by crdroidandroid.

the class LauncherUIHelper method getLauncherClassName.

/**
 * Returns the class name for the Launcher activity as defined in the manifest
 */
public static String getLauncherClassName() {
    Context context = RuntimeEnvironment.application;
    Intent homeIntent = createHomeIntent().setPackage(context.getPackageName());
    List<ResolveInfo> launchers = context.getPackageManager().queryIntentActivities(homeIntent, 0);
    if (launchers.size() != 1) {
        return null;
    }
    return launchers.get(0).activityInfo.name;
}
Also used : Context(android.content.Context) ResolveInfo(android.content.pm.ResolveInfo) Intent(android.content.Intent) Utilities.createHomeIntent(com.android.launcher3.Utilities.createHomeIntent)

Aggregations

Launcher (com.android.launcher3.Launcher)194 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)102 Test (org.junit.Test)102 View (android.view.View)87 LargeTest (androidx.test.filters.LargeTest)83 ItemInfo (com.android.launcher3.model.data.ItemInfo)83 Rect (android.graphics.Rect)80 Point (android.graphics.Point)77 Intent (android.content.Intent)71 ArrayList (java.util.ArrayList)69 DeviceProfile (com.android.launcher3.DeviceProfile)66 BaseQuickstepLauncher (com.android.launcher3.BaseQuickstepLauncher)64 Context (android.content.Context)61 LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)49 RecentsView (com.android.quickstep.views.RecentsView)46 DragLayer (com.android.launcher3.dragndrop.DragLayer)45 ComponentName (android.content.ComponentName)43 FolderInfo (com.android.launcher3.model.data.FolderInfo)42 ViewGroup (android.view.ViewGroup)41 AllApps (com.android.launcher3.tapl.AllApps)40