Merge changes Ib386c3b8,I2315e0af into main

* changes:
  Fix broken uses of TISBinder.refreshOverviewTarget
  Fix missing TAPL test state checks
This commit is contained in:
Schneider Victor-tulias
2025-04-01 07:26:27 -07:00
committed by Android (Google) Code Review
10 changed files with 119 additions and 73 deletions
@@ -174,7 +174,7 @@ public class QuickstepTestInformationHandler extends TestInformationHandler {
return response;
case TestProtocol.REQUEST_REFRESH_OVERVIEW_TARGET:
runOnTISBinder(TouchInteractionService.TISBinder::refreshOverviewTarget);
runOnTISBinder(TouchInteractionService.TISBinder::refreshOverviewTargetForTest);
return response;
case TestProtocol.REQUEST_RECREATE_TASKBAR:
@@ -73,6 +73,7 @@ import com.android.app.displaylib.PerDisplayRepository;
import com.android.launcher3.ConstantItem;
import com.android.launcher3.EncryptionType;
import com.android.launcher3.Flags;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherPrefs;
import com.android.launcher3.anim.AnimatedFloat;
import com.android.launcher3.desktop.DesktopAppLaunchTransitionManager;
@@ -96,6 +97,7 @@ import com.android.launcher3.util.TraceHelper;
import com.android.quickstep.OverviewCommandHelper.CommandType;
import com.android.quickstep.OverviewComponentObserver.OverviewChangeListener;
import com.android.quickstep.fallback.window.RecentsDisplayModel;
import com.android.quickstep.fallback.window.RecentsWindowFlags;
import com.android.quickstep.fallback.window.RecentsWindowSwipeHandler;
import com.android.quickstep.inputconsumers.BubbleBarInputConsumer;
import com.android.quickstep.inputconsumers.OneHandedModeInputConsumer;
@@ -537,10 +539,17 @@ public class TouchInteractionService extends Service {
}
/** Refreshes the current overview target. */
public void refreshOverviewTarget() {
@VisibleForTesting
public void refreshOverviewTargetForTest() {
executeForTouchInteractionService(tis -> {
tis.mAllAppsActionManager.onDestroy();
tis.onOverviewTargetChanged(tis.mOverviewComponentObserver.isHomeAndOverviewSame());
if (RecentsWindowFlags.getEnableOverviewInWindow()) {
Launcher launcher = Launcher.ACTIVITY_TRACKER.getCreatedContext();
if (launcher != null) {
tis.mTaskbarManager.setActivity(launcher);
}
}
});
}
}
@@ -37,6 +37,7 @@ import com.android.launcher3.AbstractFloatingView
import com.android.launcher3.BaseActivity
import com.android.launcher3.LauncherAnimationRunner
import com.android.launcher3.LauncherAnimationRunner.RemoteAnimationFactory
import com.android.launcher3.LauncherState
import com.android.launcher3.R
import com.android.launcher3.compat.AccessibilityManagerCompat
import com.android.launcher3.statemanager.StateManager
@@ -66,7 +67,7 @@ import com.android.quickstep.fallback.RecentsState
import com.android.quickstep.fallback.RecentsState.BACKGROUND_APP
import com.android.quickstep.fallback.RecentsState.BG_LAUNCHER
import com.android.quickstep.fallback.RecentsState.DEFAULT
import com.android.quickstep.fallback.RecentsState.HOME
import com.android.quickstep.fallback.toLauncherState
import com.android.quickstep.fallback.toLauncherStateOrdinal
import com.android.quickstep.util.RecentsAtomicAnimationFactory
import com.android.quickstep.util.RecentsWindowProtoLogProxy
@@ -361,7 +362,7 @@ class RecentsWindowManager(context: Context, wallpaperColorHints: Int) :
override fun onStateSetEnd(state: RecentsState) {
super.onStateSetEnd(state)
RecentsWindowProtoLogProxy.logOnStateSetEnd(state.toString())
if (state == HOME || state == BG_LAUNCHER) {
if (state.toLauncherState() == LauncherState.NORMAL) {
cleanupRecentsWindow()
}
AccessibilityManagerCompat.sendStateEventToTest(baseContext, state.toLauncherStateOrdinal())
@@ -27,6 +27,7 @@ import static com.android.launcher3.GestureNavContract.EXTRA_ON_FINISH_CALLBACK;
import static com.android.launcher3.GestureNavContract.EXTRA_REMOTE_CALLBACK;
import static com.android.launcher3.anim.AnimatorListeners.forEndCallback;
import android.animation.Animator;
import android.app.ActivityManager.RunningTaskInfo;
import android.content.Context;
import android.content.Intent;
@@ -58,6 +59,7 @@ import androidx.annotation.UiThread;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Utilities;
import com.android.launcher3.anim.AnimatedFloat;
import com.android.launcher3.anim.AnimationSuccessListener;
import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.anim.PendingAnimation;
import com.android.launcher3.anim.SpringAnimationBuilder;
@@ -273,8 +275,10 @@ public class RecentsWindowSwipeHandler extends AbsSwipeUpHandler<RecentsWindowMa
public AnimatorPlaybackController createActivityAnimationToHome() {
// copied from {@link LauncherSwipeHandlerV2.LauncherHomeAnimationFactory}
long accuracy = 2 * Math.max(mDp.widthPx, mDp.heightPx);
return mContainer.getStateManager().createAnimationToNewWorkspace(
RecentsState.HOME, accuracy, StateAnimationConfig.SKIP_ALL_ANIMATIONS);
return mRecentsDisplayModel.getRecentsWindowManager(mGestureState.getDisplayId())
.getStateManager()
.createAnimationToNewWorkspace(
RecentsState.HOME, accuracy, StateAnimationConfig.SKIP_ALL_ANIMATIONS);
}
}
@@ -321,9 +325,18 @@ public class RecentsWindowSwipeHandler extends AbsSwipeUpHandler<RecentsWindowMa
@NonNull
@Override
public AnimatorPlaybackController createActivityAnimationToHome() {
// TODO(b/377678992): Implement a new AtomicAnimationFactory for RecentsWindowManager
PendingAnimation pa = new PendingAnimation(mDuration);
pa.setFloat(mRecentsAlpha, AnimatedFloat.VALUE, 0, ACCELERATE);
pa.setFloat(mHomeAlpha, AnimatedFloat.VALUE, 1, ACCELERATE);
pa.addListener(new AnimationSuccessListener() {
@Override
public void onAnimationSuccess(Animator animator) {
mRecentsDisplayModel.getRecentsWindowManager(mGestureState.getDisplayId())
.getStateManager()
.goToState(RecentsState.HOME, false);
}
});
return pa.createPlaybackController();
}
@@ -34,6 +34,7 @@ import static org.mockito.Mockito.atLeast;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
@@ -62,6 +63,7 @@ import com.android.launcher3.DeviceProfile;
import com.android.launcher3.LauncherRootView;
import com.android.launcher3.dragndrop.DragLayer;
import com.android.launcher3.statemanager.BaseState;
import com.android.launcher3.statemanager.StateManager;
import com.android.launcher3.statemanager.StatefulContainer;
import com.android.launcher3.util.MSDLPlayerWrapper;
import com.android.launcher3.util.SandboxApplication;
@@ -130,6 +132,7 @@ public abstract class AbsSwipeUpHandlerTestCase<
protected RecentsAnimationTargets mRecentsAnimationTargets;
protected TaskAnimationManager mTaskAnimationManager;
protected StateManager<STATE_TYPE, RECENTS_CONTAINER> mStateManager;
@Mock protected CONTAINER_INTERFACE mActivityInterface;
@Mock protected ContextInitListener<?> mContextInitListener;
@@ -142,6 +145,7 @@ public abstract class AbsSwipeUpHandlerTestCase<
@Mock protected GestureState mGestureState;
@Mock protected MSDLPlayerWrapper mMSDLPlayerWrapper;
@Mock protected RecentsAnimationDeviceState mDeviceState;
@Mock protected StateManager.AtomicAnimationFactory<STATE_TYPE> mAtomicAnimationFactory;
@Before
public void setUpAnimationTargets() {
@@ -193,7 +197,7 @@ public abstract class AbsSwipeUpHandlerTestCase<
@Before
public void setUpRecentsContainer() {
mTaskAnimationManager = new TaskAnimationManager(mContext, DEFAULT_DISPLAY);
RecentsViewContainer recentsContainer = getRecentsContainer();
RECENTS_CONTAINER recentsContainer = getRecentsContainer();
RECENTS_VIEW recentsView = getRecentsView();
when(recentsContainer.getDeviceProfile()).thenReturn(new DeviceProfile());
@@ -201,6 +205,7 @@ public abstract class AbsSwipeUpHandlerTestCase<
when(recentsContainer.getDragLayer()).thenReturn(mDragLayer);
when(recentsContainer.getRootView()).thenReturn(mRootView);
when(recentsContainer.getSystemUiController()).thenReturn(mSystemUiController);
when(recentsContainer.createAtomicAnimationFactory()).thenReturn(mAtomicAnimationFactory);
when(mActivityInterface.createActivityInitListener(any()))
.thenReturn(mContextInitListener);
doReturn(recentsContainer).when(mActivityInterface).getCreatedContainer();
@@ -208,6 +213,10 @@ public abstract class AbsSwipeUpHandlerTestCase<
answer.<Runnable>getArgument(0).run();
return this;
}).when(recentsContainer).runOnBindToTouchInteractionService(any());
mStateManager = spy(new StateManager<>(recentsContainer, getBaseState()));
doReturn(mStateManager).when(recentsContainer).getStateManager();
}
@Test
@@ -393,8 +402,11 @@ public abstract class AbsSwipeUpHandlerTestCase<
long touchTimeMs, boolean continuingLastGesture);
@NonNull
protected abstract RecentsViewContainer getRecentsContainer();
protected abstract RECENTS_CONTAINER getRecentsContainer();
@NonNull
protected abstract RECENTS_VIEW getRecentsView();
@NonNull
protected abstract STATE_TYPE getBaseState();
}
@@ -64,4 +64,10 @@ public class FallbackSwipeHandlerTestCase extends AbsSwipeUpHandlerTestCase<
protected FallbackRecentsView<RecentsActivity> getRecentsView() {
return mRecentsView;
}
@NonNull
@Override
protected RecentsState getBaseState() {
return RecentsState.BG_LAUNCHER;
}
}
@@ -95,4 +95,10 @@ public class LauncherSwipeHandlerV2TestCase extends AbsSwipeUpHandlerTestCase<
protected RecentsView<QuickstepLauncher, LauncherState> getRecentsView() {
return mRecentsView;
}
@NonNull
@Override
protected LauncherState getBaseState() {
return LauncherState.NORMAL;
}
}
@@ -16,6 +16,9 @@
package com.android.quickstep;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.when;
import androidx.annotation.NonNull;
import androidx.test.filters.SmallTest;
@@ -28,7 +31,6 @@ import com.android.quickstep.fallback.RecentsState;
import com.android.quickstep.fallback.window.RecentsDisplayModel;
import com.android.quickstep.fallback.window.RecentsWindowManager;
import com.android.quickstep.fallback.window.RecentsWindowSwipeHandler;
import com.android.quickstep.views.RecentsViewContainer;
import dagger.BindsInstance;
import dagger.Component;
@@ -52,6 +54,9 @@ public class RecentsWindowSwipeHandlerTestCase extends AbsSwipeUpHandlerTestCase
@Before
public void setRecentsDisplayModel() {
when(mRecentsDisplayModel.getRecentsWindowManager(anyInt()))
.thenReturn(mRecentsWindowManager);
mContext.initDaggerComponent(DaggerRecentsWindowSwipeHandlerTestCase_TestComponent.builder()
.bindRecentsDisplayModel(mRecentsDisplayModel));
}
@@ -73,7 +78,7 @@ public class RecentsWindowSwipeHandlerTestCase extends AbsSwipeUpHandlerTestCase
@NonNull
@Override
protected RecentsViewContainer getRecentsContainer() {
protected RecentsWindowManager getRecentsContainer() {
return mRecentsWindowManager;
}
@@ -83,6 +88,12 @@ public class RecentsWindowSwipeHandlerTestCase extends AbsSwipeUpHandlerTestCase
return mRecentsView;
}
@NonNull
@Override
protected RecentsState getBaseState() {
return RecentsState.BG_LAUNCHER;
}
@LauncherAppSingleton
@Component(modules = {AllModulesForTest.class})
interface TestComponent extends LauncherAppComponent {
@@ -16,6 +16,8 @@
package com.android.quickstep;
import static com.android.quickstep.fallback.RecentsStateUtilsKt.toLauncherState;
import static org.junit.Assert.assertTrue;
import android.os.SystemProperties;
@@ -23,20 +25,19 @@ import android.os.SystemProperties;
import androidx.test.uiautomator.By;
import androidx.test.uiautomator.Until;
import com.android.launcher3.LauncherState;
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 org.junit.rules.RuleChain;
import org.junit.rules.TestRule;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
@@ -64,9 +65,10 @@ 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) {
protected void waitForRecentsWindowState(String message, Supplier<LauncherState> state) {
waitForRecentsWindowCondition(message, recentsWindow ->
recentsWindow.getStateManager().getCurrentStableState() == state.get());
state.get() == toLauncherState(
recentsWindow.getStateManager().getCurrentStableState()));
}
// Cannot be used in TaplTests after injecting any gesture using Tapl because this can hide
@@ -94,10 +96,10 @@ public abstract class AbstractQuickStepTest extends AbstractLauncherUiTest<Quick
Wait.atMost(message, () -> getFromRecentsWindow(condition), mLauncher, timeout);
}
protected boolean isInRecentsWindowState(Supplier<RecentsState> state) {
protected boolean isInRecentsWindowState(Supplier<LauncherState> state) {
if (!TestHelpers.isInLauncherProcess()) return true;
return getFromRecentsWindow(
recentsWindow -> recentsWindow.getStateManager().getState() == state.get());
return getFromRecentsWindow(recentsWindow ->
state.get() == toLauncherState(recentsWindow.getStateManager().getState()));
}
protected void assertTestActivityIsRunning(int activityNumber, String message) {
@@ -57,7 +57,6 @@ import com.android.launcher3.util.rule.ScreenRecordRule;
import com.android.launcher3.util.rule.TestStabilityRule;
import com.android.quickstep.NavigationModeSwitchRule.NavigationModeSwitch;
import com.android.quickstep.TaskbarModeSwitchRule.TaskbarModeSwitch;
import com.android.quickstep.fallback.RecentsState;
import com.android.quickstep.views.RecentsView;
import org.junit.After;
@@ -80,20 +79,6 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
private static final String READ_DEVICE_CONFIG_PERMISSION =
"android.permission.READ_DEVICE_CONFIG";
private enum ExpectedState {
HOME(LauncherState.NORMAL, RecentsState.HOME),
OVERVIEW(LauncherState.OVERVIEW, RecentsState.DEFAULT);
private final LauncherState mLauncherState;
private final RecentsState mRecentsState;
ExpectedState(LauncherState launcherState, RecentsState recentsState) {
this.mLauncherState = launcherState;
this.mRecentsState = recentsState;
}
}
@Before
public void setUp() throws Exception {
super.setUp();
@@ -131,7 +116,7 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
// mLauncher.pressHome() also tests an important case of pressing home while in background.
Overview overview = mLauncher.goHome().switchToOverview();
assertIsInState(
"Launcher internal state didn't switch to Overview", ExpectedState.OVERVIEW);
"Launcher internal state didn't switch to Overview", LauncherState.OVERVIEW);
runOnRecentsView(recentsView -> assertTrue("Don't have at least 3 tasks",
recentsView.getTaskViewCount() >= 3));
@@ -140,14 +125,14 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
0, recentsView.getCurrentPage()));
overview.flingForward();
assertIsInState("Launcher internal state is not Overview", ExpectedState.OVERVIEW);
assertIsInState("Launcher internal state is not Overview", LauncherState.OVERVIEW);
final Integer currentTaskAfterFlingForward =
getFromRecentsView(RecentsView::getCurrentPage);
runOnRecentsView(recentsView -> assertTrue("Current task in Overview is still 0",
currentTaskAfterFlingForward > 0));
overview.flingBackward();
assertIsInState("Launcher internal state is not Overview", ExpectedState.OVERVIEW);
assertIsInState("Launcher internal state is not Overview", LauncherState.OVERVIEW);
runOnRecentsView(recentsView -> assertTrue("Flinging back in Overview did nothing",
recentsView.getCurrentPage() < currentTaskAfterFlingForward));
@@ -163,7 +148,7 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
// Test dismissing a task.
overview = mLauncher.goHome().switchToOverview();
assertIsInState("Launcher internal state didn't switch to Overview",
ExpectedState.OVERVIEW);
LauncherState.OVERVIEW);
final Integer numTasks = getFromRecentsView(RecentsView::getTaskViewCount);
task = overview.getCurrentTask();
assertNotNull("overview.getCurrentTask() returned null (2)", task);
@@ -174,7 +159,7 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
// Test dismissing all tasks.
mLauncher.goHome().switchToOverview().dismissAllTasks();
assertIsInState("Launcher internal state is not Home", ExpectedState.HOME);
assertIsInState("Launcher internal state is not Home", LauncherState.NORMAL);
runOnRecentsView(recentsView -> assertEquals("Still have tasks after dismissing all",
0, recentsView.getTaskViewCount()));
}
@@ -198,10 +183,10 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
public void testDismissOverviewWithEscKey() throws Exception {
startTestAppsWithCheck();
final Overview overview = mLauncher.goHome().switchToOverview();
assertIsInState("Launcher internal state is not Overview", ExpectedState.OVERVIEW);
assertIsInState("Launcher internal state is not Overview", LauncherState.OVERVIEW);
overview.dismissByEscKey();
assertIsInState("Launcher internal state is not Home", ExpectedState.HOME);
assertIsInState("Launcher internal state is not Home", LauncherState.NORMAL);
}
@Test
@@ -217,14 +202,15 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
selectModeButtons = overview.getOverviewActions().clickSelect();
}
assertTrue("Launcher internal state is not Overview Modal Task",
isInState(() -> LauncherState.OVERVIEW_MODAL_TASK));
assertIsInState(
"Launcher internal state is not Overview Modal Task",
LauncherState.OVERVIEW_MODAL_TASK);
selectModeButtons.dismissByEscKey();
assertIsInState("Launcher internal state is not Overview", ExpectedState.OVERVIEW);
assertIsInState("Launcher internal state is not Overview", LauncherState.OVERVIEW);
overview.dismissByEscKey();
assertIsInState("Launcher internal state is not Home", ExpectedState.HOME);
assertIsInState("Launcher internal state is not Home", LauncherState.NORMAL);
}
@Test
@@ -232,11 +218,11 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
startTestAppsWithCheck();
startAppFast(CALCULATOR_APP_PACKAGE); // Ensure Calculator is last opened app.
Workspace home = mLauncher.goHome();
assertIsInState("Launcher state is not Home", ExpectedState.HOME);
assertIsInState("Launcher state is not Home", LauncherState.NORMAL);
Overview overview = home.openOverviewFromActionPlusTabKeyboardShortcut();
assertIsInState("Launcher state is not Overview", ExpectedState.OVERVIEW);
assertIsInState("Launcher state is not Overview", LauncherState.OVERVIEW);
overview.launchFocusedTaskByEnterKey(CALCULATOR_APP_PACKAGE); // Assert app is focused.
}
@@ -245,11 +231,11 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
startTestAppsWithCheck();
startAppFast(CALCULATOR_APP_PACKAGE); // Ensure Calculator is last opened app.
Workspace home = mLauncher.goHome();
assertIsInState("Launcher state is not Home", ExpectedState.HOME);
assertIsInState("Launcher state is not Home", LauncherState.NORMAL);
Overview overview = home.openOverviewFromRecentsKeyboardShortcut();
assertIsInState("Launcher state is not Overview", ExpectedState.OVERVIEW);
assertIsInState("Launcher state is not Overview", LauncherState.OVERVIEW);
overview.launchFocusedTaskByEnterKey(CALCULATOR_APP_PACKAGE); // Assert app is focused.
}
@@ -261,7 +247,7 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
assertNotNull("Workspace.switchToOverview() returned null",
mLauncher.goHome().switchToOverview());
assertIsInState(
"Launcher internal state didn't switch to Overview", ExpectedState.OVERVIEW);
"Launcher internal state didn't switch to Overview", LauncherState.OVERVIEW);
}
@Test
@@ -287,7 +273,7 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
assertNotNull("Background.switchToOverview() returned null",
launchedAppState.switchToOverview());
assertIsInState(
"Launcher internal state didn't switch to Overview", ExpectedState.OVERVIEW);
"Launcher internal state didn't switch to Overview", LauncherState.OVERVIEW);
}
@Test
@@ -380,11 +366,11 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
// Debug if we need to goHome to prevent wrong previous state b/315525621
mLauncher.goHome();
mLauncher.getWorkspace().switchToAllApps().pressBackToWorkspace();
waitForState("Launcher internal state didn't switch to Home", ExpectedState.HOME);
waitForState("Launcher internal state didn't switch to Home", LauncherState.NORMAL);
startAppFast(CALCULATOR_APP_PACKAGE);
mLauncher.getLaunchedAppState().pressBackToWorkspace();
waitForState("Launcher internal state didn't switch to Home", ExpectedState.HOME);
waitForState("Launcher internal state didn't switch to Home", LauncherState.NORMAL);
}
@Test
@@ -404,7 +390,7 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
// Test scroll the first task off screen
overview.scrollCurrentTaskOffScreen();
assertIsInState("Launcher internal state is not Overview", ExpectedState.OVERVIEW);
assertIsInState("Launcher internal state is not Overview", LauncherState.OVERVIEW);
runOnRecentsView(recentsView -> assertTrue("Current task in Overview is still 0",
recentsView.getCurrentPage() > 0));
@@ -420,7 +406,7 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
overview = mLauncher.goHome().switchToOverview();
overview.scrollCurrentTaskOffScreen();
assertIsInState(
"Launcher internal state is not Overview", ExpectedState.OVERVIEW);
"Launcher internal state is not Overview", LauncherState.OVERVIEW);
runOnRecentsView(recentsView -> assertTrue("Current task in Overview is still 0",
recentsView.getCurrentPage() > 0));
@@ -436,10 +422,10 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
// Test dismissing more tasks.
assertIsInState(
"Launcher internal state didn't remain in Overview", ExpectedState.OVERVIEW);
"Launcher internal state didn't remain in Overview", LauncherState.OVERVIEW);
overview.getCurrentTask().dismiss();
assertIsInState(
"Launcher internal state didn't remain in Overview", ExpectedState.OVERVIEW);
"Launcher internal state didn't remain in Overview", LauncherState.OVERVIEW);
overview.getCurrentTask().dismiss();
runOnRecentsView(recentsView -> assertTrue(
"Grid did not rebalance after multiple dismissals",
@@ -448,7 +434,7 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
// Test dismissing all tasks.
mLauncher.goHome().switchToOverview().dismissAllTasks();
assertIsInState("Launcher internal state is not Home", ExpectedState.HOME);
assertIsInState("Launcher internal state is not Home", LauncherState.NORMAL);
runOnRecentsView(recentsView -> assertEquals("Still have tasks after dismissing all",
0, recentsView.getTaskViewCount()));
}
@@ -459,18 +445,18 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
startTestAppsWithCheck();
Overview overview = mLauncher.goHome().switchToOverview();
assertIsInState("Launcher internal state should be Overview", ExpectedState.OVERVIEW);
assertIsInState("Launcher internal state should be Overview", LauncherState.OVERVIEW);
runOnRecentsView(recentsView -> assertTrue("Should have at least 3 tasks",
recentsView.getTaskViewCount() >= 3));
// It should not dismiss overview when tapping between tasks
overview.touchBetweenTasks();
overview = mLauncher.getOverview();
assertIsInState("Launcher internal state should be Overview", ExpectedState.OVERVIEW);
assertIsInState("Launcher internal state should be Overview", LauncherState.OVERVIEW);
// Dismiss when tapping to the right of the focused task
overview.touchOutsideFirstTask();
assertIsInState("Launcher internal state should be Home", ExpectedState.HOME);
assertIsInState("Launcher internal state should be Home", LauncherState.NORMAL);
}
@Test
@@ -482,28 +468,28 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
startTestAppsWithCheck();
Overview overview = mLauncher.goHome().switchToOverview();
assertIsInState("Launcher internal state should be Overview", ExpectedState.OVERVIEW);
assertIsInState("Launcher internal state should be Overview", LauncherState.OVERVIEW);
runOnRecentsView(recentsView -> assertTrue("Should have at least 3 tasks",
recentsView.getTaskViewCount() >= 3));
if (mLauncher.isTransientTaskbar()) {
// On transient taskbar, it should dismiss when tapping outside taskbar bounds.
overview.touchTaskbarBottomCorner(/* tapRight= */ false);
assertIsInState("Launcher internal state should be Normal", ExpectedState.HOME);
assertIsInState("Launcher internal state should be Normal", LauncherState.NORMAL);
overview = mLauncher.getWorkspace().switchToOverview();
// On transient taskbar, it should dismiss when tapping outside taskbar bounds.
overview.touchTaskbarBottomCorner(/* tapRight= */ true);
assertIsInState("Launcher internal state should be Normal", ExpectedState.HOME);
assertIsInState("Launcher internal state should be Normal", LauncherState.NORMAL);
} else {
// On persistent taskbar, it should not dismiss when tapping the taskbar
overview.touchTaskbarBottomCorner(/* tapRight= */ false);
assertIsInState("Launcher internal state should be Overview", ExpectedState.OVERVIEW);
assertIsInState("Launcher internal state should be Overview", LauncherState.OVERVIEW);
// On persistent taskbar, it should not dismiss when tapping the taskbar
overview.touchTaskbarBottomCorner(/* tapRight= */ true);
assertIsInState("Launcher internal state should be Overview", ExpectedState.OVERVIEW);
assertIsInState("Launcher internal state should be Overview", LauncherState.OVERVIEW);
}
}
@@ -549,7 +535,7 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
startTestAppsWithCheck();
Overview overview = mLauncher.goHome().switchToOverview();
assertIsInState("Launcher internal state didn't switch to Overview",
ExpectedState.OVERVIEW);
LauncherState.OVERVIEW);
final Integer numTasks = getFromRecentsView(RecentsView::getTaskViewCount);
OverviewTask task = overview.getCurrentTask();
assertNotNull("overview.getCurrentTask() returned null (2)", task);
@@ -571,7 +557,7 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
Overview overview = mLauncher.goHome().switchToOverview();
assertIsInState("Launcher internal state didn't switch to Overview",
ExpectedState.OVERVIEW);
LauncherState.OVERVIEW);
final Integer numTasks = getFromRecentsView(RecentsView::getTaskViewCount);
Optional<OverviewTask> bottomTask = overview.getCurrentTasksForTablet().stream().max(
Comparator.comparingInt(OverviewTask::getTaskCenterY));
@@ -598,7 +584,7 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
recentsView.getBottomRowTaskCountForTablet()));
Overview overview = mLauncher.goHome().switchToOverview();
assertIsInState("Launcher internal state didn't switch to Overview",
ExpectedState.OVERVIEW);
LauncherState.OVERVIEW);
overview.flingForwardUntilClearAllVisible();
assertTrue("Clear All not visible.", overview.isClearAllVisible());
@@ -644,18 +630,18 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
}
private void assertIsInState(
@NonNull String failureMessage, @NonNull ExpectedState expectedState) {
@NonNull String failureMessage, @NonNull LauncherState expectedState) {
assertTrue(failureMessage, enableLauncherOverviewInWindow()
? isInRecentsWindowState(() -> expectedState.mRecentsState)
: isInState(() -> expectedState.mLauncherState));
? isInRecentsWindowState(() -> expectedState)
: isInState(() -> expectedState));
}
private void waitForState(
@NonNull String failureMessage, @NonNull ExpectedState expectedState) {
@NonNull String failureMessage, @NonNull LauncherState expectedState) {
if (enableLauncherOverviewInWindow()) {
waitForRecentsWindowState(failureMessage, () -> expectedState.mRecentsState);
waitForRecentsWindowState(failureMessage, () -> expectedState);
} else {
waitForState(failureMessage, () -> expectedState.mLauncherState);
waitForState(failureMessage, () -> expectedState);
}
}