Search in sources :

Example 1 with AllAppsFromOverview

use of com.android.launcher3.tapl.AllAppsFromOverview in project Neo-Launcher by NeoApplications.

the class TaplTestsQuickstep method testOverview.

@Test
@PortraitLandscape
public void testOverview() throws Exception {
    startTestApps();
    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)));
    if (!TestHelpers.isInLauncherProcess() || getFromLauncher(launcher -> !launcher.getDeviceProfile().isLandscape)) {
        // Test switching to all apps and back.
        final AllAppsFromOverview allApps = overview.switchToAllApps();
        assertNotNull("overview.switchToAllApps() returned null (1)", allApps);
        assertTrue("Launcher internal state is not All Apps (1)", isInState(LauncherState.ALL_APPS));
        overview = allApps.switchBackToOverview();
        assertNotNull("allApps.switchBackToOverview() returned null", overview);
        assertTrue("Launcher internal state didn't switch to Overview", isInState(LauncherState.OVERVIEW));
        // Test UIDevice.pressBack()
        overview.switchToAllApps();
        assertNotNull("overview.switchToAllApps() returned null (2)", allApps);
        assertTrue("Launcher internal state is not All Apps (2)", isInState(LauncherState.ALL_APPS));
        mDevice.pressBack();
        mLauncher.getOverview();
    }
    // 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 : AndroidJUnit4(androidx.test.runner.AndroidJUnit4) Background(com.android.launcher3.tapl.Background) Overview(com.android.launcher3.tapl.Overview) TaplTestsLauncher3(com.android.launcher3.ui.TaplTestsLauncher3) RunWith(org.junit.runner.RunWith) Intent(android.content.Intent) RemoteException(android.os.RemoteException) By(androidx.test.uiautomator.By) TestHelpers(com.android.launcher3.tapl.TestHelpers) AllAppsFromOverview(com.android.launcher3.tapl.AllAppsFromOverview) NavigationModel(com.android.launcher3.tapl.LauncherInstrumentation.NavigationModel) AllApps(com.android.launcher3.tapl.AllApps) LargeTest(androidx.test.filters.LargeTest) Until(androidx.test.uiautomator.Until) Before(org.junit.Before) OverviewTask(com.android.launcher3.tapl.OverviewTask) Launcher(com.android.launcher3.Launcher) Assert.assertNotNull(org.junit.Assert.assertNotNull) TaplTestsLauncher3.getAppPackageName(com.android.launcher3.ui.TaplTestsLauncher3.getAppPackageName) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) LauncherState(com.android.launcher3.LauncherState) Ignore(org.junit.Ignore) RecentsView(com.android.quickstep.views.RecentsView) Assert.assertEquals(org.junit.Assert.assertEquals) NavigationModeSwitch(com.android.quickstep.NavigationModeSwitchRule.NavigationModeSwitch) OverviewTask(com.android.launcher3.tapl.OverviewTask) Overview(com.android.launcher3.tapl.Overview) AllAppsFromOverview(com.android.launcher3.tapl.AllAppsFromOverview) AllAppsFromOverview(com.android.launcher3.tapl.AllAppsFromOverview) LargeTest(androidx.test.filters.LargeTest) Test(org.junit.Test)

Example 2 with AllAppsFromOverview

use of com.android.launcher3.tapl.AllAppsFromOverview in project android_packages_apps_Trebuchet by LineageOS.

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)));
    if (mLauncher.hasAllAppsInOverview() && (!TestHelpers.isInLauncherProcess() || getFromLauncher(launcher -> !launcher.getDeviceProfile().isLandscape))) {
        // Test switching to all apps and back.
        final AllAppsFromOverview allApps = overview.switchToAllApps();
        assertNotNull("overview.switchToAllApps() returned null (1)", allApps);
        assertTrue("Launcher internal state is not All Apps (1)", isInState(() -> LauncherState.ALL_APPS));
        overview = allApps.switchBackToOverview();
        assertNotNull("allApps.switchBackToOverview() returned null", overview);
        assertTrue("Launcher internal state didn't switch to Overview", isInState(() -> LauncherState.OVERVIEW));
        // Test UIDevice.pressBack()
        overview.switchToAllApps();
        assertNotNull("overview.switchToAllApps() returned null (2)", allApps);
        assertTrue("Launcher internal state is not All Apps (2)", isInState(() -> LauncherState.ALL_APPS));
        mDevice.pressBack();
        mLauncher.getOverview();
    }
    // 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 : AndroidJUnit4(androidx.test.runner.AndroidJUnit4) Background(com.android.launcher3.tapl.Background) Overview(com.android.launcher3.tapl.Overview) TaplTestsLauncher3(com.android.launcher3.ui.TaplTestsLauncher3) RunWith(org.junit.runner.RunWith) OverviewActions(com.android.launcher3.tapl.OverviewActions) Intent(android.content.Intent) By(androidx.test.uiautomator.By) TestHelpers(com.android.launcher3.tapl.TestHelpers) AllAppsFromOverview(com.android.launcher3.tapl.AllAppsFromOverview) NavigationModel(com.android.launcher3.tapl.LauncherInstrumentation.NavigationModel) After(org.junit.After) AllApps(com.android.launcher3.tapl.AllApps) LargeTest(androidx.test.filters.LargeTest) Until(androidx.test.uiautomator.Until) Before(org.junit.Before) OverviewTask(com.android.launcher3.tapl.OverviewTask) Launcher(com.android.launcher3.Launcher) Assert.assertNotNull(org.junit.Assert.assertNotNull) TaplTestsLauncher3.getAppPackageName(com.android.launcher3.ui.TaplTestsLauncher3.getAppPackageName) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) LauncherState(com.android.launcher3.LauncherState) RecentsView(com.android.quickstep.views.RecentsView) Assert.assertEquals(org.junit.Assert.assertEquals) NavigationModeSwitch(com.android.quickstep.NavigationModeSwitchRule.NavigationModeSwitch) OverviewTask(com.android.launcher3.tapl.OverviewTask) Overview(com.android.launcher3.tapl.Overview) AllAppsFromOverview(com.android.launcher3.tapl.AllAppsFromOverview) AllAppsFromOverview(com.android.launcher3.tapl.AllAppsFromOverview) LargeTest(androidx.test.filters.LargeTest) Test(org.junit.Test)

Aggregations

Intent (android.content.Intent)2 LargeTest (androidx.test.filters.LargeTest)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 Overview (com.android.launcher3.tapl.Overview)2 OverviewTask (com.android.launcher3.tapl.OverviewTask)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 Assert.assertEquals (org.junit.Assert.assertEquals)2 Assert.assertNotNull (org.junit.Assert.assertNotNull)2