Search in sources :

Example 11 with OverviewTask

use of com.android.launcher3.tapl.OverviewTask in project android_packages_apps_Launcher3 by ProtonAOSP.

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 dismissing all tasks.
    mLauncher.pressHome().switchToOverview().dismissAllTasks();
    assertTrue("Launcher internal state is not Home", isInState(() -> 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 12 with OverviewTask

use of com.android.launcher3.tapl.OverviewTask in project android_packages_apps_Launcher3 by AOSPA.

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 13 with OverviewTask

use of com.android.launcher3.tapl.OverviewTask in project android_packages_apps_Launcher3 by AOSPA.

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 dismissing all tasks.
    mLauncher.pressHome().switchToOverview().dismissAllTasks();
    assertTrue("Launcher internal state is not Home", isInState(() -> 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)

Aggregations

LargeTest (androidx.test.filters.LargeTest)13 OverviewTask (com.android.launcher3.tapl.OverviewTask)13 Test (org.junit.Test)13 Overview (com.android.launcher3.tapl.Overview)7 BaseOverview (com.android.launcher3.tapl.BaseOverview)6 Intent (android.content.Intent)2 AndroidJUnit4 (androidx.test.runner.AndroidJUnit4)2 By (androidx.test.uiautomator.By)2 Until (androidx.test.uiautomator.Until)2 Launcher (com.android.launcher3.Launcher)2 LauncherState (com.android.launcher3.LauncherState)2 AllApps (com.android.launcher3.tapl.AllApps)2 AllAppsFromOverview (com.android.launcher3.tapl.AllAppsFromOverview)2 Background (com.android.launcher3.tapl.Background)2 NavigationModel (com.android.launcher3.tapl.LauncherInstrumentation.NavigationModel)2 TestHelpers (com.android.launcher3.tapl.TestHelpers)2 TaplTestsLauncher3 (com.android.launcher3.ui.TaplTestsLauncher3)2 TaplTestsLauncher3.getAppPackageName (com.android.launcher3.ui.TaplTestsLauncher3.getAppPackageName)2 NavigationModeSwitch (com.android.quickstep.NavigationModeSwitchRule.NavigationModeSwitch)2 RecentsView (com.android.quickstep.views.RecentsView)2