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

Commit b5b70930 authored by Benno Lin's avatar Benno Lin
Browse files

Enable pressback tests

Bug: 205027405
Test: Manual
Change-Id: I5bb41fc27db17e95d7a7c91cec2bbf85f33d6dad
parent 802ecf6f
Loading
Loading
Loading
Loading
+2 −14
Original line number Diff line number Diff line
@@ -32,7 +32,6 @@ import androidx.test.uiautomator.Until;

import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
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;
@@ -45,7 +44,6 @@ import com.android.quickstep.views.RecentsView;

import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;

@@ -295,26 +293,16 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
        getAndAssertLaunchedApp();
    }

    // TODO(b/204830798): test with all navigation modes(add @NavigationModeSwitch annotation)
    //  after the bug resolved.
    @Ignore("b/205027405")
    @Test
    @PortraitLandscape
    @ScreenRecord
    @NavigationModeSwitch
    public void testPressBack() throws Exception {
        mLauncher.getWorkspace().switchToAllApps();
        mLauncher.pressBack();
        mLauncher.getWorkspace();
        waitForState("Launcher internal state didn't switch to Home", () -> LauncherState.NORMAL);

        HomeAllApps allApps = mLauncher.getWorkspace().switchToAllApps();
        allApps.freeze();
        try {
            allApps.getAppIcon(APP_NAME).dragToWorkspace(false, false);
        } finally {
            allApps.unfreeze();
        }
        mLauncher.getWorkspace().getWorkspaceAppIcon(APP_NAME).launch(getAppPackageName());
        startAppFast(resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR));
        mLauncher.pressBack();
        mLauncher.getWorkspace();
        waitForState("Launcher internal state didn't switch to Home", () -> LauncherState.NORMAL);
+2 −10
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

import android.content.Intent;
import android.graphics.Point;

import androidx.test.filters.LargeTest;
@@ -50,7 +51,6 @@ import com.android.launcher3.widget.picker.WidgetsFullSheet;
import com.android.launcher3.widget.picker.WidgetsRecyclerView;

import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;

@@ -391,7 +391,6 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest {
        folder.close();
    }

    @Ignore("b/205027405")
    @Test
    @PortraitLandscape
    public void testPressBack() throws Exception {
@@ -400,14 +399,7 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest {
        mLauncher.getWorkspace();
        waitForState("Launcher internal state didn't switch to Home", () -> LauncherState.NORMAL);

        HomeAllApps allApps = mLauncher.getWorkspace().switchToAllApps();
        allApps.freeze();
        try {
            allApps.getAppIcon(APP_NAME).dragToWorkspace(false, false);
        } finally {
            allApps.unfreeze();
        }
        mLauncher.getWorkspace().getWorkspaceAppIcon(APP_NAME).launch(getAppPackageName());
        startAppFast(resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR));
        mLauncher.pressBack();
        mLauncher.getWorkspace();
        waitForState("Launcher internal state didn't switch to Home", () -> LauncherState.NORMAL);
+17 −8
Original line number Diff line number Diff line
@@ -113,6 +113,7 @@ public final class LauncherInstrumentation {

    static final Pattern EVENT_TOUCH_DOWN_TIS = getTouchEventPatternTIS("ACTION_DOWN");
    static final Pattern EVENT_TOUCH_UP_TIS = getTouchEventPatternTIS("ACTION_UP");
    static final Pattern EVENT_TOUCH_CANCEL_TIS = getTouchEventPatternTIS("ACTION_CANCEL");

    static final Pattern EVENT_KEY_BACK_DOWN = getKeyEventPattern("ACTION_DOWN", "KEYCODE_BACK");
    static final Pattern EVENT_KEY_BACK_UP = getKeyEventPattern("ACTION_UP", "KEYCODE_BACK");
@@ -135,6 +136,8 @@ public final class LauncherInstrumentation {
    public enum GestureScope {
        OUTSIDE_WITHOUT_PILFER, OUTSIDE_WITH_PILFER, INSIDE, INSIDE_TO_OUTSIDE,
        INSIDE_TO_OUTSIDE_WITHOUT_PILFER,
        INSIDE_TO_OUTSIDE_WITH_KEYCODE, // For gestures that will trigger a keycode from TIS.
        OUTSIDE_WITH_KEYCODE,
    }

    // Base class for launcher containers.
@@ -877,10 +880,9 @@ public final class LauncherInstrumentation {
    }

    /**
     * @return the Workspace object.
     * @deprecated use goHome().
     * Presses nav bar home button.
     *
     * @return the Workspace object.
     */
    @Deprecated
    public Workspace pressHome() {
@@ -968,9 +970,11 @@ public final class LauncherInstrumentation {
            if (getNavigationModel() == NavigationModel.ZERO_BUTTON) {
                final Point displaySize = getRealDisplaySize();
                final GestureScope gestureScope =
                        launcherVisible ? GestureScope.INSIDE_TO_OUTSIDE_WITHOUT_PILFER
                                : GestureScope.OUTSIDE_WITHOUT_PILFER;
                linearGesture(0, displaySize.y / 2, displaySize.x / 2, displaySize.y / 2,
                        launcherVisible ? GestureScope.INSIDE_TO_OUTSIDE_WITH_KEYCODE
                                : GestureScope.OUTSIDE_WITH_KEYCODE;
                // TODO(b/225505986): change startY and endY back to displaySize.y / 2 once the
                //  issue is solved.
                linearGesture(0, displaySize.y / 4, displaySize.x / 2, displaySize.y / 4,
                        10, false, gestureScope);
            } else {
                waitForNavigationUiObject("back").click();
@@ -1506,7 +1510,8 @@ public final class LauncherInstrumentation {
        switch (action) {
            case MotionEvent.ACTION_DOWN:
                if (gestureScope != GestureScope.OUTSIDE_WITH_PILFER
                        && gestureScope != GestureScope.OUTSIDE_WITHOUT_PILFER) {
                        && gestureScope != GestureScope.OUTSIDE_WITHOUT_PILFER
                        && gestureScope != GestureScope.OUTSIDE_WITH_KEYCODE) {
                    expectEvent(TestProtocol.SEQUENCE_MAIN, EVENT_TOUCH_DOWN);
                }
                if (notLauncher3 && getNavigationModel() != NavigationModel.THREE_BUTTON) {
@@ -1521,14 +1526,18 @@ public final class LauncherInstrumentation {
                    expectEvent(TestProtocol.SEQUENCE_PILFER, EVENT_PILFER_POINTERS);
                }
                if (gestureScope != GestureScope.OUTSIDE_WITH_PILFER
                        && gestureScope != GestureScope.OUTSIDE_WITHOUT_PILFER) {
                        && gestureScope != GestureScope.OUTSIDE_WITHOUT_PILFER
                        && gestureScope != GestureScope.OUTSIDE_WITH_KEYCODE) {
                    expectEvent(TestProtocol.SEQUENCE_MAIN,
                            gestureScope == GestureScope.INSIDE
                                    || gestureScope == GestureScope.OUTSIDE_WITHOUT_PILFER
                                    ? EVENT_TOUCH_UP : EVENT_TOUCH_CANCEL);
                }
                if (notLauncher3 && getNavigationModel() != NavigationModel.THREE_BUTTON) {
                    expectEvent(TestProtocol.SEQUENCE_TIS, EVENT_TOUCH_UP_TIS);
                    expectEvent(TestProtocol.SEQUENCE_TIS,
                            gestureScope == GestureScope.INSIDE_TO_OUTSIDE_WITH_KEYCODE
                                    || gestureScope == GestureScope.OUTSIDE_WITH_KEYCODE
                                    ? EVENT_TOUCH_CANCEL_TIS : EVENT_TOUCH_UP_TIS);
                }
                break;
        }