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

Commit bdaa179b authored by vadimt's avatar vadimt
Browse files

Consistently checking state change messages

Checking for events whenever Launcher sends them.
Checking for correct events (final events, not for events from
intermediate state changes).

This should simplify diagnosing of bugs involving TAPL.
This is also supposed to fix Fallback overview tests.

Bug: 143488140
Change-Id: If053ed808ec71bf2b652ab680be5bdfe9ff8cbb9
parent ebc50f30
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.quickstep;
import static com.android.launcher3.QuickstepAppTransitionManagerImpl.RECENTS_LAUNCH_DURATION;
import static com.android.launcher3.QuickstepAppTransitionManagerImpl.STATUS_BAR_TRANSITION_DURATION;
import static com.android.launcher3.QuickstepAppTransitionManagerImpl.STATUS_BAR_TRANSITION_PRE_DELAY;
import static com.android.launcher3.testing.TestProtocol.OVERVIEW_STATE_ORDINAL;
import static com.android.quickstep.TaskUtils.taskIsATargetWithMode;
import static com.android.quickstep.TaskViewUtils.getRecentsWindowAnimator;
import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.MODE_CLOSING;
@@ -38,6 +39,7 @@ import com.android.launcher3.InvariantDeviceProfile;
import com.android.launcher3.LauncherAnimationRunner;
import com.android.launcher3.R;
import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.compat.AccessibilityManagerCompat;
import com.android.launcher3.util.ObjectWrapper;
import com.android.launcher3.views.BaseDragLayer;
import com.android.quickstep.fallback.FallbackRecentsView;
@@ -217,6 +219,12 @@ public final class RecentsActivity extends BaseRecentsActivity {
        mFallbackRecentsView.reset();
    }

    @Override
    protected void onResume() {
        super.onResume();
        AccessibilityManagerCompat.sendStateEventToTest(getBaseContext(), OVERVIEW_STATE_ORDINAL);
    }

    public void onTaskLaunched() {
        mFallbackRecentsView.resetTaskVisuals();
    }
+6 −4
Original line number Diff line number Diff line
@@ -31,6 +31,8 @@ import static com.android.launcher3.ui.TaplTestsLauncher3.getAppPackageName;
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
import static com.android.launcher3.util.rule.ShellCommandRule.disableHeadsUpNotification;
import static com.android.launcher3.util.rule.ShellCommandRule.getLauncherCommand;
import static com.android.launcher3.util.rule.TestStabilityRule.LOCAL;
import static com.android.launcher3.util.rule.TestStabilityRule.UNBUNDLED_POSTSUBMIT;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -57,10 +59,10 @@ import com.android.launcher3.tapl.TestHelpers;
import com.android.launcher3.testcomponent.TestCommandReceiver;
import com.android.launcher3.util.Wait;
import com.android.launcher3.util.rule.FailureWatcher;
import com.android.launcher3.util.rule.TestStabilityRule;
import com.android.quickstep.NavigationModeSwitchRule.NavigationModeSwitch;
import com.android.quickstep.views.RecentsView;

import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.RuleChain;
@@ -130,7 +132,7 @@ public class FallbackRecentsTest {

    @NavigationModeSwitch
    @Test
    @Ignore // b/143488140
    @TestStabilityRule.Stability(flavors = LOCAL | UNBUNDLED_POSTSUBMIT) // b/143488140
    public void goToOverviewFromHome() {
        mDevice.pressHome();
        assertTrue("Fallback Launcher not visible", mDevice.wait(Until.hasObject(By.pkg(
@@ -141,7 +143,7 @@ public class FallbackRecentsTest {

    @NavigationModeSwitch
    @Test
    @Ignore // b/143488140
    @TestStabilityRule.Stability(flavors = LOCAL | UNBUNDLED_POSTSUBMIT) // b/143488140
    public void goToOverviewFromApp() {
        startAppFastAndWaitForRecentTask(resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR));

@@ -176,7 +178,7 @@ public class FallbackRecentsTest {

    @NavigationModeSwitch
    @Test
    @Ignore // b/143488140
    @TestStabilityRule.Stability(flavors = LOCAL | UNBUNDLED_POSTSUBMIT) // b/143488140
    public void testOverview() {
        startAppFastAndWaitForRecentTask(getAppPackageName());
        startAppFastAndWaitForRecentTask(resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR));
+13 −13
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.launcher3.tapl;

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;
import android.os.SystemClock;
@@ -54,13 +55,13 @@ public class Background extends LauncherInstrumentation.VisibleContainer {
        try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
                "want to switch from background to overview")) {
            verifyActiveContainer();
            goToOverviewUnchecked(BACKGROUND_APP_STATE_ORDINAL);
            goToOverviewUnchecked();
            return mLauncher.isFallbackOverview() ?
                    new BaseOverview(mLauncher) : new Overview(mLauncher);
        }
    }

    protected void goToOverviewUnchecked(int expectedState) {
    protected void goToOverviewUnchecked() {
        switch (mLauncher.getNavigationModel()) {
            case ZERO_BUTTON: {
                final int centerX = mLauncher.getDevice().getDisplayWidth() / 2;
@@ -81,9 +82,11 @@ public class Background extends LauncherInstrumentation.VisibleContainer {
                                start,
                                end),
                        event -> TestProtocol.PAUSE_DETECTED_MESSAGE.equals(event.getClassName()),
                        "Pause wasn't detected");
                mLauncher.sendPointer(
                        downTime, SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, end);
                        () -> "Pause wasn't detected");
                mLauncher.runToState(
                        () -> mLauncher.sendPointer(
                                downTime, SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, end),
                        OVERVIEW_STATE_ORDINAL);
                break;
            }

@@ -105,17 +108,14 @@ public class Background extends LauncherInstrumentation.VisibleContainer {
                    startY = endY = mLauncher.getDevice().getDisplayHeight() / 2;
                }

                if (mLauncher.isFallbackOverview()) {
                    mLauncher.linearGesture(startX, startY, endX, endY, 10, false);
                    new BaseOverview(mLauncher);
                } else {
                    mLauncher.swipeToState(startX, startY, endX, endY, 10, expectedState);
                }
                mLauncher.swipeToState(startX, startY, endX, endY, 10, OVERVIEW_STATE_ORDINAL);
                break;
            }

            case THREE_BUTTON:
                mLauncher.waitForSystemUiObject("recent_apps").click();
                mLauncher.runToState(
                        () -> mLauncher.waitForSystemUiObject("recent_apps").click(),
                        OVERVIEW_STATE_ORDINAL);
                break;
        }
    }
@@ -167,7 +167,7 @@ public class Background extends LauncherInstrumentation.VisibleContainer {
            case THREE_BUTTON:
                // Double press the recents button.
                UiObject2 recentsButton = mLauncher.waitForSystemUiObject("recent_apps");
                recentsButton.click();
                mLauncher.runToState(() -> recentsButton.click(), OVERVIEW_STATE_ORDINAL);
                mLauncher.getOverview();
                recentsButton.click();
                break;
+1 −2
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package com.android.launcher3.tapl;

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

import androidx.annotation.NonNull;
@@ -52,7 +51,7 @@ public abstract class Home extends Background {
        try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
                "want to switch from home to overview")) {
            verifyActiveContainer();
            goToOverviewUnchecked(OVERVIEW_STATE_ORDINAL);
            goToOverviewUnchecked();
            try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer(
                    "performed the switch action")) {
                return new Overview(mLauncher);
+1 −1
Original line number Diff line number Diff line
@@ -56,7 +56,7 @@ abstract class Launchable {
        mLauncher.executeAndWaitForEvent(
                () -> mObject.click(),
                event -> event.getEventType() == TYPE_WINDOW_STATE_CHANGED,
                "Launching an app didn't open a new window: " + mObject.getText());
                () -> "Launching an app didn't open a new window: " + mObject.getText());

        mLauncher.assertTrue(
                "App didn't start: " + selector,
Loading