Search in sources :

Example 31 with TaplTestsLauncher3.getAppPackageName

use of com.android.launcher3.ui.TaplTestsLauncher3.getAppPackageName in project android_packages_apps_404Launcher by P-404.

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 TaplTestsLauncher3.getAppPackageName

use of com.android.launcher3.ui.TaplTestsLauncher3.getAppPackageName in project android_packages_apps_404Launcher by P-404.

the class TaplTestsQuickstep method testPressBack.

// TODO(b/204830798): test with all navigation modes(add @NavigationModeSwitch annotation)
// after the bug resolved.
@Ignore("b/205027405")
@Test
@PortraitLandscape
@ScreenRecord
public void testPressBack() throws Exception {
    mLauncher.getWorkspace().switchToAllApps();
    mLauncher.pressBack();
    mLauncher.getWorkspace();
    waitForState("Launcher internal state didn't switch to Home", () -> LauncherState.NORMAL);
    AllApps allApps = mLauncher.getWorkspace().switchToAllApps();
    allApps.freeze();
    try {
        allApps.getAppIcon(APP_NAME).dragToWorkspace(false, false);
    } finally {
        allApps.unfreeze();
    }
    mLauncher.getWorkspace().getWorkspaceAppIcon(APP_NAME).launch(getAppPackageName());
    mLauncher.pressBack();
    mLauncher.getWorkspace();
    waitForState("Launcher internal state didn't switch to Home", () -> LauncherState.NORMAL);
}
Also used : AllApps(com.android.launcher3.tapl.AllApps) ScreenRecord(com.android.launcher3.util.rule.ScreenRecordRule.ScreenRecord) Ignore(org.junit.Ignore) LargeTest(androidx.test.filters.LargeTest) Test(org.junit.Test)

Example 33 with TaplTestsLauncher3.getAppPackageName

use of com.android.launcher3.ui.TaplTestsLauncher3.getAppPackageName in project android_packages_apps_404Launcher by P-404.

the class FirstScreenBroadcast method sendBroadcasts.

/**
 * Sends a broadcast to all package installers that have items with active sessions on the users
 * first screen.
 */
public void sendBroadcasts(Context context, List<ItemInfo> firstScreenItems) {
    UserHandle myUser = myUserHandle();
    mSessionInfoForPackage.values().stream().filter(info -> myUser.equals(getUserHandle(info))).collect(groupingBy(SessionInfo::getInstallerPackageName, mapping(SessionInfo::getAppPackageName, Collectors.toSet()))).forEach((installer, packages) -> sendBroadcastToInstaller(context, installer, packages, firstScreenItems));
}
Also used : InstallSessionHelper.getUserHandle(com.android.launcher3.pm.InstallSessionHelper.getUserHandle) Process.myUserHandle(android.os.Process.myUserHandle) UserHandle(android.os.UserHandle) SessionInfo(android.content.pm.PackageInstaller.SessionInfo)

Example 34 with TaplTestsLauncher3.getAppPackageName

use of com.android.launcher3.ui.TaplTestsLauncher3.getAppPackageName in project android_packages_apps_404Launcher by P-404.

the class TaplTestsLauncher3 method testDragShortcut.

@Test
@PortraitLandscape
public void testDragShortcut() throws Throwable {
    // 1. Open all apps and wait for load complete.
    // 2. Find the app and long press it to show shortcuts.
    // 3. Press icon center until shortcuts appear
    final AllApps allApps = mLauncher.getWorkspace().switchToAllApps();
    allApps.freeze();
    try {
        final AppIconMenu menu = allApps.getAppIcon(APP_NAME).openDeepShortcutMenu();
        final AppIconMenuItem menuItem0 = menu.getMenuItem(0);
        final AppIconMenuItem menuItem2 = menu.getMenuItem(2);
        final AppIconMenuItem menuItem;
        final String expectedShortcutName = "Shortcut 3";
        if (menuItem0.getText().equals(expectedShortcutName)) {
            menuItem = menuItem0;
        } else {
            final String shortcutName2 = menuItem2.getText();
            assertEquals("Wrong menu item", expectedShortcutName, shortcutName2);
            menuItem = menuItem2;
        }
        menuItem.dragToWorkspace(false, false);
        mLauncher.getWorkspace().getWorkspaceAppIcon(expectedShortcutName).launch(getAppPackageName());
    } finally {
        allApps.unfreeze();
    }
}
Also used : AllApps(com.android.launcher3.tapl.AllApps) AppIconMenu(com.android.launcher3.tapl.AppIconMenu) AppIconMenuItem(com.android.launcher3.tapl.AppIconMenuItem) LargeTest(androidx.test.filters.LargeTest) Test(org.junit.Test)

Example 35 with TaplTestsLauncher3.getAppPackageName

use of com.android.launcher3.ui.TaplTestsLauncher3.getAppPackageName in project android_packages_apps_404Launcher by P-404.

the class TaplTestsLauncher3 method testPressBack.

@Ignore("b/205027405")
@Test
@PortraitLandscape
public void testPressBack() throws Exception {
    mLauncher.getWorkspace().switchToAllApps();
    mLauncher.pressBack();
    mLauncher.getWorkspace();
    waitForState("Launcher internal state didn't switch to Home", () -> LauncherState.NORMAL);
    AllApps allApps = mLauncher.getWorkspace().switchToAllApps();
    allApps.freeze();
    try {
        allApps.getAppIcon(APP_NAME).dragToWorkspace(false, false);
    } finally {
        allApps.unfreeze();
    }
    mLauncher.getWorkspace().getWorkspaceAppIcon(APP_NAME).launch(getAppPackageName());
    mLauncher.pressBack();
    mLauncher.getWorkspace();
    waitForState("Launcher internal state didn't switch to Home", () -> LauncherState.NORMAL);
}
Also used : AllApps(com.android.launcher3.tapl.AllApps) Ignore(org.junit.Ignore) LargeTest(androidx.test.filters.LargeTest) Test(org.junit.Test)

Aggregations

LargeTest (androidx.test.filters.LargeTest)55 Test (org.junit.Test)55 AllApps (com.android.launcher3.tapl.AllApps)33 OverviewTask (com.android.launcher3.tapl.OverviewTask)13 AppIconMenu (com.android.launcher3.tapl.AppIconMenu)12 AppIconMenuItem (com.android.launcher3.tapl.AppIconMenuItem)12 Overview (com.android.launcher3.tapl.Overview)11 Intent (android.content.Intent)9 Ignore (org.junit.Ignore)9 PendingIntent (android.app.PendingIntent)7 AddToHomeScreenPrompt (com.android.launcher3.tapl.AddToHomeScreenPrompt)7 AppIcon (com.android.launcher3.tapl.AppIcon)7 Widget (com.android.launcher3.tapl.Widget)7 RequestPinItemActivity (com.android.launcher3.testcomponent.RequestPinItemActivity)7 AbstractLauncherUiTest (com.android.launcher3.ui.AbstractLauncherUiTest)7 LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)6 BaseOverview (com.android.launcher3.tapl.BaseOverview)6 SessionInfo (android.content.pm.PackageInstaller.SessionInfo)5 Process.myUserHandle (android.os.Process.myUserHandle)5 UserHandle (android.os.UserHandle)5