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

Commit 40b6a19f authored by Brian Isganitis's avatar Brian Isganitis Committed by Android (Google) Code Review
Browse files

Merge "Make dismissByTappingOutsideForTablet an API of AllApps super class." into main

parents 195fc85d 171b4289
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -151,6 +151,13 @@ public class TaplTestsTaskbar extends AbstractTaplTestsTaskbar {
                .dragToSplitscreen(TEST_APP_PACKAGE, CALCULATOR_APP_PACKAGE);
    }

    @Test
    @PortraitLandscape
    public void testDismissAllAppsByTappingOutsideSheet() {
        getTaskbar().openAllApps().dismissByTappingOutsideForTablet(/* tapRight= */ true);
        getTaskbar().openAllApps().dismissByTappingOutsideForTablet(/* tapRight= */ false);
    }

    private boolean isTaskbarTestModeTransient() {
        return TRANSIENT == mTaskbarMode;
    }
+24 −0
Original line number Diff line number Diff line
@@ -48,6 +48,8 @@ public abstract class AllApps extends LauncherInstrumentation.VisibleContainer {

    private static final int MAX_SCROLL_ATTEMPTS = 40;

    private static final String BOTTOM_SHEET_RES_ID = "bottom_sheet_background";

    private final int mHeight;
    private final int mIconHeight;

@@ -337,6 +339,28 @@ public abstract class AllApps extends LauncherInstrumentation.VisibleContainer {
        return testInfo == null ? 0 : testInfo.getInt(TestProtocol.TEST_INFO_RESPONSE_FIELD);
    }

    /**
     * Taps outside bottom sheet to dismiss it. Available on tablets only.
     * @param tapRight Tap on the right of bottom sheet if true, or left otherwise.
     */
    public void dismissByTappingOutsideForTablet(boolean tapRight) {
        mLauncher.assertTrue("Device must be a tablet", mLauncher.isTablet());
        try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck();
             LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
                     "want to tap outside AllApps bottom sheet on the "
                             + (tapRight ? "right" : "left"))) {
            final UiObject2 allAppsBottomSheet =
                    mLauncher.waitForLauncherObject(BOTTOM_SHEET_RES_ID);
            mLauncher.touchOutsideContainer(allAppsBottomSheet, tapRight);
            try (LauncherInstrumentation.Closable tapped = mLauncher.addContextLayer(
                    "tapped outside AllApps bottom sheet")) {
                verifyVisibleContainerOnDismiss();
            }
        }
    }

    protected abstract void verifyVisibleContainerOnDismiss();

    /**
     * Return the QSB UI object on the AllApps screen.
     * @return the QSB UI object.
+5 −20
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@ import androidx.test.uiautomator.UiObject2;
import com.android.launcher3.testing.shared.TestProtocol;

public class HomeAllApps extends AllApps {
    private static final String BOTTOM_SHEET_RES_ID = "bottom_sheet_background";

    HomeAllApps(LauncherInstrumentation launcher) {
        super(launcher);
@@ -98,25 +97,6 @@ public class HomeAllApps extends AllApps {
                .getInt(TestProtocol.TEST_INFO_RESPONSE_FIELD);
    }

    /**
     * Taps outside bottom sheet to dismiss and return to workspace. Available on tablets only.
     * @param tapRight Tap on the right of bottom sheet if true, or left otherwise.
     */
    public Workspace dismissByTappingOutsideForTablet(boolean tapRight) {
        try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck();
             LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
                     "want to tap outside AllApps bottom sheet on the "
                             + (tapRight ? "right" : "left"))) {
            final UiObject2 allAppsBottomSheet =
                    mLauncher.waitForLauncherObject(BOTTOM_SHEET_RES_ID);
            mLauncher.touchOutsideContainer(allAppsBottomSheet, tapRight);
            try (LauncherInstrumentation.Closable tapped = mLauncher.addContextLayer(
                    "tapped outside AllApps bottom sheet")) {
                return mLauncher.getWorkspace();
            }
        }
    }

    @NonNull
    @Override
    public Qsb getQsb() {
@@ -128,4 +108,9 @@ public class HomeAllApps extends AllApps {
        return mLauncher.getTestInfo(TestProtocol.REQUEST_APPS_LIST_SCROLL_Y)
                .getInt(TestProtocol.TEST_INFO_RESPONSE_FIELD);
    }

    @Override
    protected void verifyVisibleContainerOnDismiss() {
        mLauncher.getWorkspace();
    }
}
+5 −0
Original line number Diff line number Diff line
@@ -68,4 +68,9 @@ public class TaskbarAllApps extends AllApps {
    public TaskbarAllAppsQsb getQsb() {
        return new TaskbarAllAppsQsb(mLauncher, verifyActiveContainer());
    }

    @Override
    protected void verifyVisibleContainerOnDismiss() {
        mLauncher.getLaunchedAppState().assertTaskbarVisible();
    }
}