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 Diff line number Diff line
@@ -221,13 +221,9 @@ public class PortraitStatesTouchController extends AbstractStateChangeTouchContr
     * @return true if the event is over the hotseat
     */
    static boolean isTouchOverHotseat(Launcher launcher, MotionEvent ev) {
        return (ev.getY() >= getHotseatTop(launcher));
    }

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

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

import androidx.annotation.Nullable;

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

public class QuickstepTestInformationHandler extends TestInformationHandler {
@@ -26,15 +24,6 @@ public class QuickstepTestInformationHandler extends TestInformationHandler {
    public Bundle call(String method, String arg, @Nullable Bundle extras) {
        final Bundle response = new Bundle();
        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: {
                final float swipeHeight =
                        LayoutUtils.getDefaultSwipeHeight(mContext, mDeviceProfile);
@@ -50,11 +39,6 @@ public class QuickstepTestInformationHandler extends TestInformationHandler {
                return response;
            }

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

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

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

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

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

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

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

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

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

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

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

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

        // Test dismissing a task.
        overview = mLauncher.pressHome().switchToOverview();
@@ -210,21 +210,22 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
    @PortraitLandscape
    public void testBackground() throws Exception {
        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",
                isInState(() -> LauncherState.OVERVIEW));
    }

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

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

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

        background = getAndAssertBackground();
        background.quickSwitchToPreviousApp();
        launchedAppState = getAndAssertLaunchedApp();
        launchedAppState.quickSwitchToPreviousApp();
        if (mLauncher.getNavigationModel() == NavigationModel.THREE_BUTTON) {
            // 3-button mode toggles between 2 apps, rather than going back further.
            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",
                    isTestActivityRunning(2));
        }
        background = getAndAssertBackground();
        background.quickSwitchToPreviousAppSwipeLeft();
        launchedAppState = getAndAssertLaunchedApp();
        launchedAppState.quickSwitchToPreviousAppSwipeLeft();
        assertTrue("The 2nd app we should have quick switched to is not running",
                isTestActivityRunning(3));

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

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

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

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