Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 64162f1e authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Update TAPL object hierarchy in preparation for Taskbar TAPL tests"

parents b63aad9d d6279ae6
Loading
Loading
Loading
Loading
+1 −5
Original line number Original line Diff line number Diff line
@@ -221,13 +221,9 @@ public class PortraitStatesTouchController extends AbstractStateChangeTouchContr
     * @return true if the event is over the hotseat
     * @return true if the event is over the hotseat
     */
     */
    static boolean isTouchOverHotseat(Launcher launcher, MotionEvent ev) {
    static boolean isTouchOverHotseat(Launcher launcher, MotionEvent ev) {
        return (ev.getY() >= getHotseatTop(launcher));
    }

    public static int getHotseatTop(Launcher launcher) {
        DeviceProfile dp = launcher.getDeviceProfile();
        DeviceProfile dp = launcher.getDeviceProfile();
        int hotseatHeight = dp.hotseatBarSizePx + dp.getInsets().bottom;
        int hotseatHeight = dp.hotseatBarSizePx + dp.getInsets().bottom;
        return launcher.getDragLayer().getHeight() - hotseatHeight;
        return (ev.getY() >= (launcher.getDragLayer().getHeight() - hotseatHeight));
    }
    }


    @Override
    @Override
+0 −16
Original line number Original line Diff line number Diff line
@@ -7,11 +7,9 @@ import android.os.Bundle;


import androidx.annotation.Nullable;
import androidx.annotation.Nullable;


import com.android.launcher3.LauncherState;
import com.android.launcher3.testing.TestInformationHandler;
import com.android.launcher3.testing.TestInformationHandler;
import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.touch.PagedOrientationHandler;
import com.android.launcher3.touch.PagedOrientationHandler;
import com.android.launcher3.uioverrides.touchcontrollers.PortraitStatesTouchController;
import com.android.quickstep.util.LayoutUtils;
import com.android.quickstep.util.LayoutUtils;


public class QuickstepTestInformationHandler extends TestInformationHandler {
public class QuickstepTestInformationHandler extends TestInformationHandler {
@@ -26,15 +24,6 @@ public class QuickstepTestInformationHandler extends TestInformationHandler {
    public Bundle call(String method, String arg, @Nullable Bundle extras) {
    public Bundle call(String method, String arg, @Nullable Bundle extras) {
        final Bundle response = new Bundle();
        final Bundle response = new Bundle();
        switch (method) {
        switch (method) {
            case TestProtocol.REQUEST_ALL_APPS_TO_OVERVIEW_SWIPE_HEIGHT: {
                return getLauncherUIProperty(Bundle::putInt, l -> {
                    final float progress = LauncherState.OVERVIEW.getVerticalProgress(l)
                            - LauncherState.ALL_APPS.getVerticalProgress(l);
                    final float distance = l.getAllAppsController().getShiftRange() * progress;
                    return (int) distance;
                });
            }

            case TestProtocol.REQUEST_HOME_TO_OVERVIEW_SWIPE_HEIGHT: {
            case TestProtocol.REQUEST_HOME_TO_OVERVIEW_SWIPE_HEIGHT: {
                final float swipeHeight =
                final float swipeHeight =
                        LayoutUtils.getDefaultSwipeHeight(mContext, mDeviceProfile);
                        LayoutUtils.getDefaultSwipeHeight(mContext, mDeviceProfile);
@@ -50,11 +39,6 @@ public class QuickstepTestInformationHandler extends TestInformationHandler {
                return response;
                return response;
            }
            }


            case TestProtocol.REQUEST_HOTSEAT_TOP: {
                return getLauncherUIProperty(
                        Bundle::putInt, PortraitStatesTouchController::getHotseatTop);
            }

            case TestProtocol.REQUEST_GET_FOCUSED_TASK_HEIGHT_FOR_TABLET: {
            case TestProtocol.REQUEST_GET_FOCUSED_TASK_HEIGHT_FOR_TABLET: {
                if (!mDeviceProfile.isTablet) {
                if (!mDeviceProfile.isTablet) {
                    return null;
                    return null;
+4 −4
Original line number Original line Diff line number Diff line
@@ -165,7 +165,7 @@ public class FallbackRecentsTest {
        assertTrue("Fallback Launcher not visible", mDevice.wait(Until.hasObject(By.pkg(
        assertTrue("Fallback Launcher not visible", mDevice.wait(Until.hasObject(By.pkg(
                mOtherLauncherActivity.packageName)), WAIT_TIME_MS));
                mOtherLauncherActivity.packageName)), WAIT_TIME_MS));


        mLauncher.getBackground().switchToOverview();
        mLauncher.getLaunchedAppState().switchToOverview();
    }
    }


    // b/143488140
    // b/143488140
@@ -174,7 +174,7 @@ public class FallbackRecentsTest {
    public void goToOverviewFromApp() {
    public void goToOverviewFromApp() {
        startAppFast(resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR));
        startAppFast(resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR));


        mLauncher.getBackground().switchToOverview();
        mLauncher.getLaunchedAppState().switchToOverview();
    }
    }


    protected void executeOnRecents(Consumer<RecentsActivity> f) {
    protected void executeOnRecents(Consumer<RecentsActivity> f) {
@@ -200,7 +200,7 @@ public class FallbackRecentsTest {


    private BaseOverview pressHomeAndGoToOverview() {
    private BaseOverview pressHomeAndGoToOverview() {
        mDevice.pressHome();
        mDevice.pressHome();
        return mLauncher.getBackground().switchToOverview();
        return mLauncher.getLaunchedAppState().switchToOverview();
    }
    }


    // b/143488140
    // b/143488140
@@ -213,7 +213,7 @@ public class FallbackRecentsTest {
        Wait.atMost("Expected three apps in the task list",
        Wait.atMost("Expected three apps in the task list",
                () -> mLauncher.getRecentTasks().size() >= 3, DEFAULT_ACTIVITY_TIMEOUT, mLauncher);
                () -> mLauncher.getRecentTasks().size() >= 3, DEFAULT_ACTIVITY_TIMEOUT, mLauncher);


        BaseOverview overview = mLauncher.getBackground().switchToOverview();
        BaseOverview overview = mLauncher.getLaunchedAppState().switchToOverview();
        executeOnRecents(recents -> {
        executeOnRecents(recents -> {
            assertTrue("Don't have at least 3 tasks", getTaskCount(recents) >= 3);
            assertTrue("Don't have at least 3 tasks", getTaskCount(recents) >= 3);
        });
        });
+1 −1
Original line number Original line Diff line number Diff line
@@ -78,7 +78,7 @@ public class StartLauncherViaGestureTests extends AbstractQuickStepTest {
            closeLauncherActivity();
            closeLauncherActivity();


            // The test action.
            // The test action.
            mLauncher.getBackground().switchToOverview();
            mLauncher.getLaunchedAppState().switchToOverview();
        }
        }
        closeLauncherActivity();
        closeLauncherActivity();
        mLauncher.pressHome();
        mLauncher.pressHome();
+22 −21
Original line number Original line Diff line number Diff line
@@ -32,8 +32,8 @@ import androidx.test.uiautomator.Until;


import com.android.launcher3.Launcher;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
import com.android.launcher3.LauncherState;
import com.android.launcher3.tapl.AllApps;
import com.android.launcher3.tapl.HomeAllApps;
import com.android.launcher3.tapl.Background;
import com.android.launcher3.tapl.LaunchedAppState;
import com.android.launcher3.tapl.LauncherInstrumentation.NavigationModel;
import com.android.launcher3.tapl.LauncherInstrumentation.NavigationModel;
import com.android.launcher3.tapl.Overview;
import com.android.launcher3.tapl.Overview;
import com.android.launcher3.tapl.OverviewActions;
import com.android.launcher3.tapl.OverviewActions;
@@ -84,7 +84,7 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
        executeOnLauncher(launcher -> assertTrue(
        executeOnLauncher(launcher -> assertTrue(
                "Launcher activity is the top activity; expecting another activity to be the top "
                "Launcher activity is the top activity; expecting another activity to be the top "
                        + "one",
                        + "one",
                isInBackground(launcher)));
                isInLaunchedApp(launcher)));
    }
    }


    @Test
    @Test
@@ -136,7 +136,7 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
        executeOnLauncher(launcher -> assertTrue(
        executeOnLauncher(launcher -> assertTrue(
                "Launcher activity is the top activity; expecting another activity to be the top "
                "Launcher activity is the top activity; expecting another activity to be the top "
                        + "one",
                        + "one",
                isInBackground(launcher)));
                isInLaunchedApp(launcher)));


        // Test dismissing a task.
        // Test dismissing a task.
        overview = mLauncher.pressHome().switchToOverview();
        overview = mLauncher.pressHome().switchToOverview();
@@ -210,21 +210,22 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
    @PortraitLandscape
    @PortraitLandscape
    public void testBackground() throws Exception {
    public void testBackground() throws Exception {
        startAppFast(resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR));
        startAppFast(resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR));
        final Background background = getAndAssertBackground();
        final LaunchedAppState launchedAppState = getAndAssertLaunchedApp();


        assertNotNull("Background.switchToOverview() returned null", background.switchToOverview());
        assertNotNull("Background.switchToOverview() returned null",
                launchedAppState.switchToOverview());
        assertTrue("Launcher internal state didn't switch to Overview",
        assertTrue("Launcher internal state didn't switch to Overview",
                isInState(() -> LauncherState.OVERVIEW));
                isInState(() -> LauncherState.OVERVIEW));
    }
    }


    private Background getAndAssertBackground() {
    private LaunchedAppState getAndAssertLaunchedApp() {
        final Background background = mLauncher.getBackground();
        final LaunchedAppState launchedAppState = mLauncher.getLaunchedAppState();
        assertNotNull("Launcher.getBackground() returned null", background);
        assertNotNull("Launcher.getLaunchedApp() returned null", launchedAppState);
        executeOnLauncher(launcher -> assertTrue(
        executeOnLauncher(launcher -> assertTrue(
                "Launcher activity is the top activity; expecting another activity to be the top "
                "Launcher activity is the top activity; expecting another activity to be the top "
                        + "one",
                        + "one",
                isInBackground(launcher)));
                isInLaunchedApp(launcher)));
        return background;
        return launchedAppState;
    }
    }


    @Test
    @Test
@@ -253,13 +254,13 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
        startTestActivity(3);
        startTestActivity(3);
        startTestActivity(4);
        startTestActivity(4);


        Background background = getAndAssertBackground();
        LaunchedAppState launchedAppState = getAndAssertLaunchedApp();
        background.quickSwitchToPreviousApp();
        launchedAppState.quickSwitchToPreviousApp();
        assertTrue("The first app we should have quick switched to is not running",
        assertTrue("The first app we should have quick switched to is not running",
                isTestActivityRunning(3));
                isTestActivityRunning(3));


        background = getAndAssertBackground();
        launchedAppState = getAndAssertLaunchedApp();
        background.quickSwitchToPreviousApp();
        launchedAppState.quickSwitchToPreviousApp();
        if (mLauncher.getNavigationModel() == NavigationModel.THREE_BUTTON) {
        if (mLauncher.getNavigationModel() == NavigationModel.THREE_BUTTON) {
            // 3-button mode toggles between 2 apps, rather than going back further.
            // 3-button mode toggles between 2 apps, rather than going back further.
            assertTrue("Second quick switch should have returned to the first app.",
            assertTrue("Second quick switch should have returned to the first app.",
@@ -268,13 +269,13 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
            assertTrue("The second app we should have quick switched to is not running",
            assertTrue("The second app we should have quick switched to is not running",
                    isTestActivityRunning(2));
                    isTestActivityRunning(2));
        }
        }
        background = getAndAssertBackground();
        launchedAppState = getAndAssertLaunchedApp();
        background.quickSwitchToPreviousAppSwipeLeft();
        launchedAppState.quickSwitchToPreviousAppSwipeLeft();
        assertTrue("The 2nd app we should have quick switched to is not running",
        assertTrue("The 2nd app we should have quick switched to is not running",
                isTestActivityRunning(3));
                isTestActivityRunning(3));


        background = getAndAssertBackground();
        launchedAppState = getAndAssertLaunchedApp();
        background.switchToOverview();
        launchedAppState.switchToOverview();
    }
    }


    private boolean isTestActivityRunning(int activityNumber) {
    private boolean isTestActivityRunning(int activityNumber) {
@@ -291,7 +292,7 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
        mLauncher.pressHome().quickSwitchToPreviousApp();
        mLauncher.pressHome().quickSwitchToPreviousApp();
        assertTrue("The most recent task is not running after quick switching from home",
        assertTrue("The most recent task is not running after quick switching from home",
                isTestActivityRunning(2));
                isTestActivityRunning(2));
        getAndAssertBackground();
        getAndAssertLaunchedApp();
    }
    }


    // TODO(b/204830798): test with all navigation modes(add @NavigationModeSwitch annotation)
    // TODO(b/204830798): test with all navigation modes(add @NavigationModeSwitch annotation)
@@ -306,7 +307,7 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
        mLauncher.getWorkspace();
        mLauncher.getWorkspace();
        waitForState("Launcher internal state didn't switch to Home", () -> LauncherState.NORMAL);
        waitForState("Launcher internal state didn't switch to Home", () -> LauncherState.NORMAL);


        AllApps allApps = mLauncher.getWorkspace().switchToAllApps();
        HomeAllApps allApps = mLauncher.getWorkspace().switchToAllApps();
        allApps.freeze();
        allApps.freeze();
        try {
        try {
            allApps.getAppIcon(APP_NAME).dragToWorkspace(false, false);
            allApps.getAppIcon(APP_NAME).dragToWorkspace(false, false);
Loading