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

Commit 9c07fc13 authored by Alex Chau's avatar Alex Chau
Browse files

Re-land "Update Tapl tests for enable_grid_only_overview"

- Fix getCurrentTask() to correctly get the top-right tasks in grid only overview. It'll first get the widest task, and then top, and then rightmost task
- Fix scrollLeftByDistance() to correctly account for leftGestureMargin to make sure it scroll by distance provided
- Fix scrollCurrentTaskOffScreen() to actually scroll the task off screen
- Fix createAndLaunchASplitPair() to use Task menu instead of Overview actions for grid only overview
- Skip testOverviewActions() in grid only overview, where Overview actions isn't available
- Fix testOverivewForTablet to expect the correct task in grid only overview; also disabled part of a test due to an animation bug in Overview
- Fix dismissBySwipingUp() to swipe from bottom of task, which is required to effectively dismiss top row tasks
- Also fixed OverviewTask to correctly get objects in FallbackOverview
- Fix touchOutsideContainer() to calcualte y base on container's middle correctly

Bug: 283246928
Test: presubmit
Flag: None
Change-Id: I77e91dcc1a404ade356b29fba6cf967c534c08f4
parent 39c548bd
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -92,7 +92,7 @@ public class TaplOverviewIconTest extends AbstractLauncherUiTest {
        startTestActivity(2);
        startTestActivity(3);

        if (mLauncher.isTablet()) {
        if (mLauncher.isTablet() && !mLauncher.isGridOnlyOverviewEnabled()) {
            mLauncher.goHome().switchToOverview().getOverviewActions()
                    .clickSplit()
                    .getTestActivityTask(2)
+16 −11
Original line number Diff line number Diff line
@@ -179,6 +179,8 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
    @PortraitLandscape
    @PlatinumTest(focusArea = "launcher")
    public void testOverviewActions() throws Exception {
        assumeFalse("Skipping Overview Actions tests for grid only overview",
                mLauncher.isTablet() && mLauncher.isGridOnlyOverviewEnabled());
        // Experimenting for b/165029151:
        final Overview overview = mLauncher.goHome().switchToOverview();
        if (overview.hasTasks()) overview.dismissAllTasks();
@@ -377,7 +379,9 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
        // Test opening the task.
        overview.getCurrentTask().open();
        assertTrue("Test activity didn't open from Overview",
                mDevice.wait(Until.hasObject(By.pkg(getAppPackageName()).text("TestActivity10")),
                mDevice.wait(Until.hasObject(By.pkg(getAppPackageName()).text(
                                mLauncher.isGridOnlyOverviewEnabled() ? "TestActivity12"
                                        : "TestActivity13")),
                        DEFAULT_UI_TIMEOUT));

        // Scroll the task offscreen as it is now first
@@ -398,16 +402,17 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
                (Math.abs(getTopRowTaskCountForTablet(launcher) - getBottomRowTaskCountForTablet(
                        launcher)) <= 1)));

        // Test dismissing more tasks.
        assertTrue("Launcher internal state didn't remain in Overview",
                isInState(() -> LauncherState.OVERVIEW));
        overview.getCurrentTask().dismiss();
        assertTrue("Launcher internal state didn't remain in Overview",
                isInState(() -> LauncherState.OVERVIEW));
        overview.getCurrentTask().dismiss();
        executeOnLauncher(launcher -> assertTrue("Grid did not rebalance after multiple dismissals",
                (Math.abs(getTopRowTaskCountForTablet(launcher) - getBottomRowTaskCountForTablet(
                        launcher)) <= 1)));
        // TODO(b/308841019): Re-enable after fixing Overview jank when dismiss
//        // Test dismissing more tasks.
//        assertTrue("Launcher internal state didn't remain in Overview",
//                isInState(() -> LauncherState.OVERVIEW));
//        overview.getCurrentTask().dismiss();
//        assertTrue("Launcher internal state didn't remain in Overview",
//                isInState(() -> LauncherState.OVERVIEW));
//        overview.getCurrentTask().dismiss();
//        executeOnLauncher(launcher -> assertTrue("Grid did not rebalance after multiple dismissals",
//                (Math.abs(getTopRowTaskCountForTablet(launcher) - getBottomRowTaskCountForTablet(
//                        launcher)) <= 1)));

        // Test dismissing all tasks.
        mLauncher.goHome().switchToOverview().dismissAllTasks();
+1 −1
Original line number Diff line number Diff line
@@ -143,7 +143,7 @@ public class TaplTestsSplitscreen extends AbstractQuickStepTest {
        startTestActivity(2);
        startTestActivity(3);

        if (mLauncher.isTablet()) {
        if (mLauncher.isTablet() && !mLauncher.isGridOnlyOverviewEnabled()) {
            mLauncher.goHome().switchToOverview().getOverviewActions()
                    .clickSplit()
                    .getTestActivityTask(2)
+11 −9
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import androidx.test.uiautomator.Direction;
import androidx.test.uiautomator.UiObject2;

import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

@@ -201,7 +202,8 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer {
            OverviewTask task = getCurrentTask();
            mLauncher.assertNotNull("current task is null", task);
            mLauncher.scrollLeftByDistance(verifyActiveContainer(),
                    task.getVisibleWidth() + mLauncher.getOverviewPageSpacing());
                    mLauncher.getRealDisplaySize().x - task.getUiObject().getVisibleBounds().left
                            + mLauncher.getOverviewPageSpacing());

            try (LauncherInstrumentation.Closable c2 =
                         mLauncher.addContextLayer("scrolled task off screen")) {
@@ -231,14 +233,14 @@ public class BaseOverview extends LauncherInstrumentation.VisibleContainer {
        final List<UiObject2> taskViews = getTasks();
        mLauncher.assertNotEquals("Unable to find a task", 0, taskViews.size());

        // taskViews contains up to 3 task views: the 'main' (having the widest visible part) one
        // in the center, and parts of its right and left siblings. Find the main task view by
        // its width.
        final UiObject2 widestTask = Collections.max(taskViews,
                (t1, t2) -> Integer.compare(mLauncher.getVisibleBounds(t1).width(),
                        mLauncher.getVisibleBounds(t2).width()));

        return new OverviewTask(mLauncher, widestTask, this);
        final List<OverviewTask> overviewTasks = taskViews.stream().map(
                task -> new OverviewTask(mLauncher, task, this)).toList();
        // The widest, and most top-right task should be the current task
        return Collections.max(overviewTasks,
                Comparator.comparingInt(OverviewTask::getVisibleWidth)
                        .thenComparingInt(OverviewTask::getTaskCenterX)
                        .thenComparing(
                                Comparator.comparing(OverviewTask::getTaskCenterY).reversed()));
    }

    /** Returns an overview task matching TestActivity {@param activityNumber}. */
+7 −4
Original line number Diff line number Diff line
@@ -1608,8 +1608,11 @@ public final class LauncherInstrumentation {
        scroll(
                container,
                Direction.LEFT,
                new Rect(leftGestureMargin, 0,
                        containerRect.width() - distance - rightGestureMarginInContainer, 0),
                new Rect(leftGestureMargin,
                        0,
                        Math.max(containerRect.width() - distance - leftGestureMargin,
                                rightGestureMarginInContainer),
                        0),
                10,
                true);
    }
@@ -1782,7 +1785,7 @@ public final class LauncherInstrumentation {
                TestProtocol.TEST_INFO_RESPONSE_FIELD);
    }

    boolean isGridOnlyOverviewEnabled() {
    public boolean isGridOnlyOverviewEnabled() {
        return getTestInfo(TestProtocol.REQUEST_FLAG_ENABLE_GRID_ONLY_OVERVIEW).getBoolean(
                TestProtocol.TEST_INFO_RESPONSE_FIELD);
    }
@@ -2225,7 +2228,7 @@ public final class LauncherInstrumentation {
            int bottomBound = Math.min(
                    containerBounds.bottom,
                    getRealDisplaySize().y - getImeInsets().bottom);
            int y = (bottomBound - containerBounds.top) / 2;
            int y = (bottomBound + containerBounds.top) / 2;
            // Do not tap in the status bar.
            y = Math.max(y, getWindowInsets().top);

Loading