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

Commit a140a0b6 authored by Pat Manning's avatar Pat Manning
Browse files

Add TAPL test that dismissing focused task causes next task to become

focused.

Test: TaplTestsQuickstep.java
Bug: 197630182
Change-Id: I6f29dc6e3954f1b22ce8ffdf0a83db97202caefe
parent 9114f280
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -53,14 +53,14 @@ public class QuickstepTestInformationHandler extends TestInformationHandler {
                        Bundle::putInt, PortraitStatesTouchController::getHotseatTop);
            }

            case TestProtocol.REQUEST_GET_FOCUSED_TASK_WIDTH_FOR_TABLET: {
            case TestProtocol.REQUEST_GET_FOCUSED_TASK_HEIGHT_FOR_TABLET: {
                if (!mDeviceProfile.isTablet) {
                    return null;
                }
                Rect focusedTaskRect = new Rect();
                LauncherActivityInterface.INSTANCE.calculateTaskSize(mContext, mDeviceProfile,
                        focusedTaskRect);
                response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, focusedTaskRect.width());
                response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, focusedTaskRect.height());
                return response;
            }
        }
+2 −2
Original line number Diff line number Diff line
@@ -102,8 +102,8 @@ public final class TestProtocol {
    public static final String REQUEST_GET_ACTIVITIES_CREATED_COUNT =
            "get-activities-created-count";
    public static final String REQUEST_GET_ACTIVITIES = "get-activities";
    public static final String REQUEST_GET_FOCUSED_TASK_WIDTH_FOR_TABLET =
            "get-focused-task-width-for-tablet";
    public static final String REQUEST_GET_FOCUSED_TASK_HEIGHT_FOR_TABLET =
            "get-focused-task-height-for-tablet";

    public static Long sForcePauseTimeout;
    public static final String REQUEST_SET_FORCE_PAUSE_TIMEOUT = "set-force-pause-timeout";
+11 −11
Original line number Diff line number Diff line
@@ -138,6 +138,10 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer {
        }
    }

    int getTaskCount() {
        return getTasks().size();
    }

    /**
     * Returns whether Overview has tasks.
     */
@@ -169,7 +173,7 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer {
        }
        try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
                "want to assert overview actions view visibility")) {
            if (mLauncher.isTablet() && !isOverviewSnappedToFocusedTask()) {
            if (mLauncher.isTablet() && !isOverviewSnappedToFocusedTaskForTablet()) {
                mLauncher.waitUntilLauncherObjectGone("action_buttons");
            } else {
                mLauncher.waitForLauncherObject("action_buttons");
@@ -178,14 +182,10 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer {
    }

    /**
     * Returns if focused task is currently snapped task in overview.
     * Returns if focused task is currently snapped task in tablet grid overview.
     */
    private boolean isOverviewSnappedToFocusedTask() {
        if (!mLauncher.isTablet()) {
            // Focused task only exists in tablet's grid-overview
            return false;
        }
        UiObject2 focusedTask = getFocusedTask();
    private boolean isOverviewSnappedToFocusedTaskForTablet() {
        UiObject2 focusedTask = getFocusedTaskForTablet();
        if (focusedTask == null) {
            return false;
        }
@@ -197,14 +197,14 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer {
    /**
     * Returns Overview focused task if it exists.
     */
    private UiObject2 getFocusedTask() {
    UiObject2 getFocusedTaskForTablet() {
        final List<UiObject2> taskViews = getTasks();
        if (taskViews.size() == 0) {
            return null;
        }
        int focusedTaskWidth = mLauncher.getFocusedTaskWidth();
        int focusedTaskHeight = mLauncher.getFocusedTaskHeightForTablet();
        for (UiObject2 task : taskViews) {
            if (task.getVisibleBounds().width() == focusedTaskWidth) {
            if (task.getVisibleBounds().height() == focusedTaskHeight) {
                return task;
            }
        }
+2 −2
Original line number Diff line number Diff line
@@ -321,8 +321,8 @@ public final class LauncherInstrumentation {
                .getBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD);
    }

    int getFocusedTaskWidth() {
        return getTestInfo(TestProtocol.REQUEST_GET_FOCUSED_TASK_WIDTH_FOR_TABLET).getInt(
    int getFocusedTaskHeightForTablet() {
        return getTestInfo(TestProtocol.REQUEST_GET_FOCUSED_TASK_HEIGHT_FOR_TABLET).getInt(
                TestProtocol.TEST_INFO_RESPONSE_FIELD);
    }

+38 −14
Original line number Diff line number Diff line
@@ -47,13 +47,40 @@ public final class OverviewTask {
        mOverview.verifyActiveContainer();
    }

    private int getVisibleHeight() {
        return mTask.getVisibleBounds().height();
    }

    /**
     * Swipes the task up.
     * Dismisses the task by swiping up.
     */
    public void dismiss() {
        try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck();
             LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
                     "want to dismiss a task")) {
                     "want to dismiss an overview task")) {
            verifyActiveContainer();
            int taskCountBeforeDismiss = mOverview.getTaskCount();
            mLauncher.assertNotEquals("Unable to find a task", 0, taskCountBeforeDismiss);
            if (taskCountBeforeDismiss == 1) {
                dismissBySwipingUp();
                return;
            }

            boolean taskWasFocused = mLauncher.isTablet() && getVisibleHeight() == mLauncher
                    .getFocusedTaskHeightForTablet();

            dismissBySwipingUp();

            try (LauncherInstrumentation.Closable c2 = mLauncher.addContextLayer("dismissed")) {
                if (taskWasFocused) {
                    mLauncher.assertNotNull("No task became focused",
                            mOverview.getFocusedTaskForTablet());
                }
            }
        }
    }

    private void dismissBySwipingUp() {
        verifyActiveContainer();
        // Dismiss the task via flinging it up.
        final Rect taskBounds = mLauncher.getVisibleBounds(mTask);
@@ -62,12 +89,9 @@ public final class OverviewTask {
        mLauncher.executeAndWaitForLauncherEvent(
                () -> mLauncher.linearGesture(centerX, centerY, centerX, 0, 10, false,
                        LauncherInstrumentation.GestureScope.INSIDE),
                    event -> TestProtocol.DISMISS_ANIMATION_ENDS_MESSAGE.equals(
                            event.getClassName()),
                event -> TestProtocol.DISMISS_ANIMATION_ENDS_MESSAGE.equals(event.getClassName()),
                () -> "Didn't receive a dismiss animation ends message: " + centerX + ", "
                            + centerY,
                    "swiping to dismiss");
        }
                        + centerY, "swiping to dismiss");
    }

    /**