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

Commit 429b8df1 authored by Pat Manning's avatar Pat Manning Committed by Android (Google) Code Review
Browse files

Merge "Add TAPL tests for hiding the actions view when scrolling away from...

Merge "Add TAPL tests for hiding the actions view when scrolling away from focused task in overview." into sc-v2-dev
parents ba4b8e14 35231f30
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@ package com.android.quickstep;

import android.app.Activity;
import android.content.Context;
import android.graphics.Rect;
import android.os.Bundle;

import com.android.launcher3.LauncherState;
@@ -58,6 +59,17 @@ public class QuickstepTestInformationHandler extends TestInformationHandler {
                        FeatureFlags.ENABLE_OVERVIEW_SHARE.get());
                return response;
            }

            case TestProtocol.REQUEST_GET_FOCUSED_TASK_WIDTH_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());
                return response;
            }
        }

        return super.call(method, arg);
+2 −0
Original line number Diff line number Diff line
@@ -102,6 +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 Long sForcePauseTimeout;
    public static final String REQUEST_SET_FORCE_PAUSE_TIMEOUT = "set-force-pause-timeout";
+62 −2
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer {
    BaseOverview(LauncherInstrumentation launcher) {
        super(launcher);
        verifyActiveContainer();
        verifyActionsViewVisibility();
    }

    @Override
@@ -59,7 +60,11 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer {
            final int leftMargin = mLauncher.getTargetInsets().left;
            mLauncher.scroll(
                    overview, Direction.LEFT, new Rect(leftMargin + 1, 0, 0, 0), 20, false);
            try (LauncherInstrumentation.Closable c2 =
                         mLauncher.addContextLayer("flung forwards")) {
                verifyActiveContainer();
                verifyActionsViewVisibility();
            }
        }
    }

@@ -95,7 +100,11 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer {
            final int rightMargin = mLauncher.getTargetInsets().right;
            mLauncher.scroll(
                    overview, Direction.RIGHT, new Rect(0, 0, rightMargin + 1, 0), 20, false);
            try (LauncherInstrumentation.Closable c2 =
                         mLauncher.addContextLayer("flung backwards")) {
                verifyActiveContainer();
                verifyActionsViewVisibility();
            }
        }
    }

@@ -150,4 +159,55 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer {
            return new OverviewActions(overviewActions, mLauncher);
        }
    }

    /* TODO(b/197630182): Once b/188790554 is fixed, remove instanceof check. Currently, when
        swiping from app to overview in Fallback Recents, taskbar remains and no action buttons
        are visible, so we are only testing Overview for now, not BaseOverview. */
    private void verifyActionsViewVisibility() {
        if (!(this instanceof Overview)) {
            return;
        }
        try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
                "want to assert overview actions view visibility")) {
            if (mLauncher.isTablet() && !isOverviewSnappedToFocusedTask()) {
                mLauncher.waitUntilLauncherObjectGone("action_buttons");
            } else {
                mLauncher.waitForLauncherObject("action_buttons");
            }
        }
    }

    /**
     * Returns if focused task is currently snapped task in overview.
     */
    private boolean isOverviewSnappedToFocusedTask() {
        if (!mLauncher.isTablet()) {
            // Focused task only exists in tablet's grid-overview
            return false;
        }
        UiObject2 focusedTask = getFocusedTask();
        if (focusedTask == null) {
            return false;
        }
        return Math.abs(
                focusedTask.getVisibleBounds().exactCenterX() - mLauncher.getExactScreenCenterX())
                < 1;
    }

    /**
     * Returns Overview focused task if it exists.
     */
    private UiObject2 getFocusedTask() {
        final List<UiObject2> taskViews = getTasks();
        if (taskViews.size() == 0) {
            return null;
        }
        int focusedTaskWidth = mLauncher.getFocusedTaskWidth();
        for (UiObject2 task : taskViews) {
            if (task.getVisibleBounds().width() == focusedTaskWidth) {
                return task;
            }
        }
        return null;
    }
}
 No newline at end of file
+9 −0
Original line number Diff line number Diff line
@@ -321,6 +321,15 @@ public final class LauncherInstrumentation {
                .getBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD);
    }

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

    float getExactScreenCenterX() {
        return getRealDisplaySize().x / 2f;
    }

    private void setForcePauseTimeout(long timeout) {
        getTestInfo(TestProtocol.REQUEST_SET_FORCE_PAUSE_TIMEOUT, Long.toString(timeout));
    }
+0 −1
Original line number Diff line number Diff line
@@ -30,7 +30,6 @@ public final class Overview extends BaseOverview {

    Overview(LauncherInstrumentation launcher) {
        super(launcher);
        verifyActiveContainer();
    }

    @Override