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

Commit cfc2e02a authored by vadimt's avatar vadimt
Browse files

TAPL: switching all swipes to model time

Bug: 133010773
Change-Id: I3334ac4ac434bf1c6470c806bb216eb7bd8e22c2
parent a1a417c9
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -53,9 +53,9 @@ public final class AllAppsFromOverview extends AllApps {
                    TestProtocol.REQUEST_ALL_APPS_TO_OVERVIEW_SWIPE_HEIGHT).
                    getInt(TestProtocol.TEST_INFO_RESPONSE_FIELD);

            final int endY = start.y + swipeHeight + mLauncher.getTouchSlop();
            final int endY = start.y + swipeHeight;
            LauncherInstrumentation.log("AllAppsFromOverview.switchBackToOverview before swipe");
            mLauncher.swipe(start.x, start.y, start.x, endY, OVERVIEW_STATE_ORDINAL);
            mLauncher.swipeToState(start.x, start.y, start.x, endY, 60, OVERVIEW_STATE_ORDINAL);

            try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer("swiped down")) {
                return new Overview(mLauncher);
+2 −1
Original line number Diff line number Diff line
@@ -86,9 +86,10 @@ public class Background extends LauncherInstrumentation.VisibleContainer {
                final int swipeHeight = mLauncher.getTestInfo(getSwipeHeightRequestName()).
                        getInt(TestProtocol.TEST_INFO_RESPONSE_FIELD);

                mLauncher.swipe(
                mLauncher.swipeToState(
                        centerX, startY, centerX,
                        startY - swipeHeight - mLauncher.getTouchSlop(),
                        60,
                        expectedState);
                break;
            }
+8 −23
Original line number Diff line number Diff line
@@ -584,18 +584,15 @@ public final class LauncherInstrumentation {
        return mDevice;
    }

    void swipe(int startX, int startY, int endX, int endY, int expectedState) {
        swipe(startX, startY, endX, endY, expectedState, 60);
    }

    void swipe(int startX, int startY, int endX, int endY, int expectedState, int steps) {
        changeStateViaGesture(startX, startY, endX, endY, expectedState,
                () -> mDevice.swipe(startX, startY, endX, endY, steps));
    }

    void swipeToState(int startX, int startY, int endX, int endY, int steps, int expectedState) {
        changeStateViaGesture(startX, startY, endX, endY, expectedState,
                () -> linearGesture(startX, startY, endX, endY, steps));
        final Bundle parcel = (Bundle) executeAndWaitForEvent(
                () -> linearGesture(startX, startY, endX, endY, steps),
                event -> TestProtocol.SWITCHED_TO_STATE_MESSAGE.equals(event.getClassName()),
                "Swipe failed to receive an event for the swipe end: " + startX + ", " + startY
                        + ", " + endX + ", " + endY);
        assertEquals("Swipe switched launcher to a wrong state;",
                TestProtocol.stateOrdinalToString(expectedState),
                TestProtocol.stateOrdinalToString(parcel.getInt(TestProtocol.STATE_FIELD)));
    }

    void scroll(UiObject2 container, Direction direction, float percent, Rect margins, int steps) {
@@ -652,18 +649,6 @@ public final class LauncherInstrumentation {
        sendPointer(downTime, endTime, MotionEvent.ACTION_UP, end);
    }

    private void changeStateViaGesture(int startX, int startY, int endX, int endY,
            int expectedState, Runnable gesture) {
        final Bundle parcel = (Bundle) executeAndWaitForEvent(
                gesture,
                event -> TestProtocol.SWITCHED_TO_STATE_MESSAGE.equals(event.getClassName()),
                "Swipe failed to receive an event for the swipe end: " + startX + ", " + startY
                        + ", " + endX + ", " + endY);
        assertEquals("Swipe switched launcher to a wrong state;",
                TestProtocol.stateOrdinalToString(expectedState),
                TestProtocol.stateOrdinalToString(parcel.getInt(TestProtocol.STATE_FIELD)));
    }

    void waitForIdle() {
        mDevice.waitForIdle();
    }