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

Commit e873a171 authored by vadimt's avatar vadimt
Browse files

Expecting TYPE_WINDOW_STATE_CHANGED in quick switch

Bug: 142654442
Change-Id: I48c8d929952872e444d1a3f7a40721d8edcd8942
parent 884fc469
Loading
Loading
Loading
Loading
+54 −52
Original line number Diff line number Diff line
@@ -16,8 +16,9 @@

package com.android.launcher3.tapl;

import static android.view.accessibility.AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED;

import static com.android.launcher3.tapl.OverviewTask.TASK_START_EVENT;
import static com.android.launcher3.testing.TestProtocol.BACKGROUND_APP_STATE_ORDINAL;
import static com.android.launcher3.testing.TestProtocol.OVERVIEW_STATE_ORDINAL;

import android.graphics.Point;
@@ -150,21 +151,12 @@ public class Background extends LauncherInstrumentation.VisibleContainer {
    /**
     * Swipes right or double presses the square button to switch to the previous app.
     */
    @NonNull
    public Background quickSwitchToPreviousApp() {
        try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck();
             LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
                     "want to quick switch to the previous app")) {
            verifyActiveContainer();
            quickSwitchToPreviousApp(getExpectedStateForQuickSwitch());
            return new Background(mLauncher);
        }
    }

    protected int getExpectedStateForQuickSwitch() {
        return BACKGROUND_APP_STATE_ORDINAL;
    }

    protected void quickSwitchToPreviousApp(int expectedState) {
            final boolean launcherWasVisible = mLauncher.isLauncherVisible();
            boolean transposeInLandscape = false;
            switch (mLauncher.getNavigationModel()) {
@@ -191,10 +183,15 @@ public class Background extends LauncherInstrumentation.VisibleContainer {
                    }
                    final boolean isZeroButton = mLauncher.getNavigationModel()
                            == LauncherInstrumentation.NavigationModel.ZERO_BUTTON;
                mLauncher.swipeToState(startX, startY, endX, endY, 20, expectedState,
                    LauncherInstrumentation.GestureScope gestureScope =
                            launcherWasVisible && isZeroButton
                                    ? LauncherInstrumentation.GestureScope.INSIDE_TO_OUTSIDE
                                : LauncherInstrumentation.GestureScope.OUTSIDE_WITH_PILFER);
                                    : LauncherInstrumentation.GestureScope.OUTSIDE_WITH_PILFER;
                    mLauncher.executeAndWaitForEvent(
                            () -> mLauncher.linearGesture(
                                    startX, startY, endX, endY, 20, false, gestureScope),
                            event -> event.getEventType() == TYPE_WINDOW_STATE_CHANGED,
                            () -> "Quick switch gesture didn't change window state");
                    break;
                }

@@ -205,10 +202,15 @@ public class Background extends LauncherInstrumentation.VisibleContainer {
                    mLauncher.runToState(() -> recentsButton.click(), OVERVIEW_STATE_ORDINAL);
                    mLauncher.getOverview();
                    mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, SQUARE_BUTTON_EVENT);
                recentsButton.click();
                    mLauncher.executeAndWaitForEvent(
                            () -> recentsButton.click(),
                            event -> event.getEventType() == TYPE_WINDOW_STATE_CHANGED,
                            () -> "Pressing recents button didn't change window state");
                    break;
            }
            mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, TASK_START_EVENT);
            return new Background(mLauncher);
        }
    }

    protected String getSwipeHeightRequestName() {
+0 −6
Original line number Diff line number Diff line
@@ -16,8 +16,6 @@

package com.android.launcher3.tapl;

import static com.android.launcher3.testing.TestProtocol.QUICK_SWITCH_STATE_ORDINAL;

import androidx.annotation.NonNull;

/**
@@ -65,8 +63,4 @@ public abstract class Home extends Background {
        return true;
    }

    @Override
    protected int getExpectedStateForQuickSwitch() {
        return QUICK_SWITCH_STATE_ORDINAL;
    }
}
 No newline at end of file