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

Commit 76e1676c authored by Schneider Victor-Tulias's avatar Schneider Victor-Tulias
Browse files

Update TaplTestsQuickstep to expect recents window states when enabled

Flag: com.android.launcher3.enable_fallback_overview_in_window
Fixes: 382527932
Test: TaplTestsQuickstep
Change-Id: I14f66628105fab5d8c39ae7f9fd9ebfa61a268b7
parent 37deb21b
Loading
Loading
Loading
Loading
+18 −16
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ import com.android.launcher3.statemanager.StateManager
import com.android.launcher3.statemanager.StateManager.AtomicAnimationFactory
import com.android.launcher3.statemanager.StatefulContainer
import com.android.launcher3.taskbar.TaskbarUIController
import com.android.launcher3.testing.shared.TestProtocol.NORMAL_STATE_ORDINAL
import com.android.launcher3.testing.shared.TestProtocol.OVERVIEW_STATE_ORDINAL
import com.android.launcher3.util.ContextTracker
import com.android.launcher3.util.DisplayController
@@ -88,10 +89,8 @@ import java.util.function.Predicate
 * To add new protologs, see [RecentsWindowProtoLogProxy]. To enable logging to logcat, see
 * [QuickstepProtoLogGroup.Constants.DEBUG_RECENTS_WINDOW]
 */
class RecentsWindowManager(
    private val displayId: Int,
    context: Context
) : RecentsWindowContext(context), RecentsViewContainer, StatefulContainer<RecentsState> {
class RecentsWindowManager(private val displayId: Int, context: Context) :
    RecentsWindowContext(context), RecentsViewContainer, StatefulContainer<RecentsState> {

    companion object {
        private const val HOME_APPEAR_DURATION: Long = 250
@@ -113,7 +112,7 @@ class RecentsWindowManager(
    private var layoutInflater: LayoutInflater = LayoutInflater.from(this).cloneInContext(this)
    private var stateManager: StateManager<RecentsState, RecentsWindowManager> =
        StateManager<RecentsState, RecentsWindowManager>(this, RecentsState.BG_LAUNCHER)
    private var mSystemUiController: SystemUiController? = null
    private var systemUiController: SystemUiController? = null

    private var dragLayer: RecentsDragLayer<RecentsWindowManager>? = null
    private var windowView: View? = null
@@ -126,7 +125,7 @@ class RecentsWindowManager(
    private var tisBindHelper: TISBindHelper = TISBindHelper(this) {}

    // Callback array that corresponds to events defined in @ActivityEvent
    private val mEventCallbacks =
    private val eventCallbacks =
        listOf(RunnableList(), RunnableList(), RunnableList(), RunnableList())
    private var onInitListener: Predicate<Boolean>? = null

@@ -184,7 +183,7 @@ class RecentsWindowManager(
    }

    private fun startHomeInternal() {
        val runner = LauncherAnimationRunner(mainThreadHandler, mAnimationToHomeFactory, true)
        val runner = LauncherAnimationRunner(mainThreadHandler, animationToHomeFactory, true)
        val options =
            ActivityOptions.makeRemoteAnimation(
                RemoteAnimationAdapter(runner, HOME_APPEAR_DURATION, 0),
@@ -198,7 +197,7 @@ class RecentsWindowManager(
        stateManager.moveToRestState()
    }

    private val mAnimationToHomeFactory =
    private val animationToHomeFactory =
        RemoteAnimationFactory {
            _: Int,
            appTargets: Array<RemoteAnimationTarget>?,
@@ -289,7 +288,7 @@ class RecentsWindowManager(
        actionsView?.updateDimension(getDeviceProfile(), recentsView?.lastComputedTaskSize)
        actionsView?.updateVerticalMargin(DisplayController.getNavigationMode(this))

        mSystemUiController = SystemUiController(windowView)
        systemUiController = SystemUiController(windowView)
        recentsWindowTracker.handleCreate(this)

        this.callbacks = callbacks
@@ -359,7 +358,10 @@ class RecentsWindowManager(
        if (state == HOME || state == BG_LAUNCHER) {
            cleanupRecentsWindow()
        }
        if (state === DEFAULT) {
        when (state) {
            HOME ->
                AccessibilityManagerCompat.sendStateEventToTest(baseContext, NORMAL_STATE_ORDINAL)
            DEFAULT ->
                AccessibilityManagerCompat.sendStateEventToTest(baseContext, OVERVIEW_STATE_ORDINAL)
        }
    }
@@ -378,10 +380,10 @@ class RecentsWindowManager(
    }

    override fun getSystemUiController(): SystemUiController? {
        if (mSystemUiController == null) {
            mSystemUiController = SystemUiController(rootView)
        if (systemUiController == null) {
            systemUiController = SystemUiController(rootView)
        }
        return mSystemUiController
        return systemUiController
    }

    override fun getContext(): Context {
@@ -432,12 +434,12 @@ class RecentsWindowManager(

    /** Adds a callback for the provided activity event */
    override fun addEventCallback(@BaseActivity.ActivityEvent event: Int, callback: Runnable?) {
        mEventCallbacks[event].add(callback)
        eventCallbacks[event].add(callback)
    }

    /** Removes a previously added callback */
    override fun removeEventCallback(@BaseActivity.ActivityEvent event: Int, callback: Runnable?) {
        mEventCallbacks[event].remove(callback)
        eventCallbacks[event].remove(callback)
    }

    override fun runOnBindToTouchInteractionService(r: Runnable?) {
+59 −0
Original line number Diff line number Diff line
@@ -20,18 +20,28 @@ import static org.junit.Assert.assertTrue;

import android.os.SystemProperties;

import androidx.annotation.NonNull;
import androidx.test.uiautomator.By;
import androidx.test.uiautomator.Until;

import com.android.launcher3.tapl.LaunchedAppState;
import com.android.launcher3.tapl.TestHelpers;
import com.android.launcher3.ui.AbstractLauncherUiTest;
import com.android.launcher3.uioverrides.QuickstepLauncher;
import com.android.launcher3.util.TestUtil;
import com.android.launcher3.util.Wait;
import com.android.quickstep.fallback.RecentsState;
import com.android.quickstep.fallback.window.RecentsWindowManager;
import com.android.quickstep.views.RecentsView;
import com.android.quickstep.views.RecentsViewContainer;

import org.junit.rules.RuleChain;
import org.junit.rules.TestRule;

import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;

/**
 * Base class for all instrumentation tests that deal with Quickstep.
 */
@@ -54,6 +64,55 @@ public abstract class AbstractQuickStepTest extends AbstractLauncherUiTest<Quick
        }
    }

    // Cannot be used in TaplTests between a Tapl call injecting a gesture and a tapl call
    // expecting the results of that gesture because the wait can hide flakeness.
    protected void waitForRecentsWindowState(String message, Supplier<RecentsState> state) {
        waitForRecentsWindowCondition(message, recentsWindow ->
                recentsWindow.getStateManager().getCurrentStableState() == state.get());
    }

    // Cannot be used in TaplTests after injecting any gesture using Tapl because this can hide
    // flakiness.
    protected void waitForRecentsWindowCondition(String
            message, Function<RecentsWindowManager, Boolean> condition) {
        waitForRecentsWindowCondition(message, condition, TestUtil.DEFAULT_UI_TIMEOUT);
    }

    protected <T> T getFromRecentsWindowManager(Function<RecentsWindowManager, T> f) {
        if (!TestHelpers.isInLauncherProcess()) return null;
        return getOnUiThread(
                () -> f.apply(RecentsWindowManager.getRecentsWindowTracker().getCreatedContext()));
    }

    protected void executeOnRecentsWindow(Consumer<RecentsWindowManager> f) {
        getFromRecentsWindowManager(recentsWindow -> {
            f.accept(recentsWindow);
            return null;
        });
    }

    protected void executeOnRecentsViewContainerInTearDown(
            @NonNull Consumer<RecentsViewContainer> f) {
        executeOnRecentsWindow(container -> {
            if (container != null) f.accept(container);
        });
    }

    // Cannot be used in TaplTests after injecting any gesture using Tapl because this can hide
    // flakiness.
    protected void waitForRecentsWindowCondition(
            String message, Function<RecentsWindowManager, Boolean> condition, long timeout) {
        verifyKeyguardInvisible();
        if (!TestHelpers.isInLauncherProcess()) return;
        Wait.atMost(message, () -> getFromRecentsWindowManager(condition), mLauncher, timeout);
    }

    protected boolean isInRecentsWindowState(Supplier<RecentsState> state) {
        if (!TestHelpers.isInLauncherProcess()) return true;
        return getFromRecentsWindowManager(
                recentsWindow -> recentsWindow.getStateManager().getState() == state.get());
    }

    protected void assertTestActivityIsRunning(int activityNumber, String message) {
        assertTrue(message, mDevice.wait(
                Until.hasObject(By.pkg(getAppPackageName()).text("TestActivity" + activityNumber)),
+139 −107

File changed.

Preview size limit exceeded, changes collapsed.