fix: Conflict incoming changes from 15-dev

This commit is contained in:
Pun Butrach committed 2026-01-10 20:49:12 +07:00
1 parent 14e352c827
commit 2e76c99dad
1726 files changed
+146970 -95027

No files matched your search

@@ -16,20 +16,25 @@
package com.android.quickstep;
import static com.android.quickstep.fallback.RecentsStateUtilsKt.hasEquivalentRecentsState;
import static com.android.quickstep.fallback.RecentsStateUtilsKt.toLauncherState;
import static org.junit.Assert.assertTrue;
import android.os.SystemProperties;
import androidx.annotation.Nullable;
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.launcher3.util.ui.AbstractLauncherUiTest;
import com.android.quickstep.fallback.window.RecentsWindowFlags;
import com.android.quickstep.fallback.window.RecentsWindowManager;
import com.android.quickstep.views.RecentsView;
@@ -43,7 +48,8 @@ import java.util.function.Supplier;
/**
* Base class for all instrumentation tests that deal with Quickstep.
*/
public abstract class AbstractQuickStepTest extends AbstractLauncherUiTest<QuickstepLauncher> {
public abstract class AbstractQuickStepTest
extends AbstractLauncherUiTest<QuickstepLauncher, RecentsView<?, ?>> {
public static final boolean ENABLE_SHELL_TRANSITIONS =
SystemProperties.getBoolean("persist.wm.debug.shell_transit", true);
@Override
@@ -56,19 +62,16 @@ public abstract class AbstractQuickStepTest extends AbstractLauncherUiTest<Quick
@Override
protected void onLauncherActivityClose(QuickstepLauncher launcher) {
super.onLauncherActivityClose(launcher);
if (RecentsWindowFlags.enableLauncherOverviewInWindow) {
executeOnRecentsWindowIfPresent(RecentsWindowManager::cleanupRecentsWindow);
}
RecentsView recentsView = launcher.getOverviewPanel();
if (recentsView != null) {
recentsView.finishRecentsAnimation(false /* toRecents */, null);
}
}
// 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
@@ -76,15 +79,6 @@ public abstract class AbstractQuickStepTest extends AbstractLauncherUiTest<Quick
waitForRecentsWindowCondition(message, condition, TestUtil.DEFAULT_UI_TIMEOUT);
}
protected <T> T getFromRecentsWindow(Function<RecentsWindowManager, T> f) {
if (!TestHelpers.isInLauncherProcess()) return null;
return getOnUiThread(() -> {
RecentsWindowManager recentsWindowManager =
RecentsWindowManager.getRecentsWindowTracker().getCreatedContext();
return recentsWindowManager != null ? f.apply(recentsWindowManager) : null;
});
}
// Cannot be used in TaplTests after injecting any gesture using Tapl because this can hide
// flakiness.
protected void waitForRecentsWindowCondition(
@@ -94,10 +88,68 @@ public abstract class AbstractQuickStepTest extends AbstractLauncherUiTest<Quick
Wait.atMost(message, () -> getFromRecentsWindow(condition), mLauncher, timeout);
}
protected boolean isInRecentsWindowState(Supplier<RecentsState> state) {
protected <T> T getFromRecentsWindowIfPresent(Function<RecentsWindowManager, T> f) {
if (!TestHelpers.isInLauncherProcess()) return null;
return getFromRecentsWindow(recentsWindowManager ->
recentsWindowManager == null ? null : f.apply(recentsWindowManager));
}
protected <T> T getFromRecentsWindow(Function<RecentsWindowManager, T> f) {
if (!TestHelpers.isInLauncherProcess()) return null;
return getOnUiThread(() ->
f.apply(RecentsWindowManager.getRecentsWindowTracker().getCreatedContext()));
}
protected void executeOnRecentsWindowIfPresent(Consumer<RecentsWindowManager> f) {
if (!TestHelpers.isInLauncherProcess()) return;
getFromRecentsWindowIfPresent(recentsWindowManager -> {
f.accept(recentsWindowManager);
return null;
});
}
@Override
protected boolean isInState(Supplier<LauncherState> state) {
if (!TestHelpers.isInLauncherProcess()) return true;
return getFromRecentsWindow(
recentsWindow -> recentsWindow.getStateManager().getState() == state.get());
if (!RecentsWindowFlags.enableLauncherOverviewInWindow
|| !hasEquivalentRecentsState(state.get())) {
return super.isInState(state);
}
return getFromRecentsWindow(recentsWindowManager ->
recentsWindowManager != null && toLauncherState(
recentsWindowManager.getStateManager().getState()) == state.get());
}
@Override
protected void waitForState(
boolean forInitialization, String message, Supplier<LauncherState> state) {
if (!TestHelpers.isInLauncherProcess()) return;
if (!RecentsWindowFlags.enableLauncherOverviewInWindow
|| !hasEquivalentRecentsState(state.get())
|| (forInitialization
&& RecentsWindowManager.getRecentsWindowTracker().getCreatedContext() == null)) {
super.waitForState(forInitialization, message, state);
return;
}
waitForRecentsWindowCondition(message, recentsWindowManager ->
recentsWindowManager != null && toLauncherState(
recentsWindowManager.getStateManager().getState()) == state.get());
}
@Override
@Nullable
protected RecentsView getOverviewPanel() {
if (!TestHelpers.isInLauncherProcess()) return null;
if (!RecentsWindowFlags.enableLauncherOverviewInWindow) {
return super.getOverviewPanel();
}
return getFromRecentsWindowIfPresent(RecentsWindowManager::getOverviewPanel);
}
@Override
protected boolean useNullOverview() {
return super.useNullOverview()
&& !RecentsWindowFlags.enableLauncherOverviewInWindow;
}
protected void assertTestActivityIsRunning(int activityNumber, String message) {
@@ -24,10 +24,10 @@ import android.content.Intent;
import com.android.launcher3.tapl.LauncherInstrumentation;
import com.android.launcher3.tapl.Taskbar;
import com.android.launcher3.ui.AbstractLauncherUiTest;
import com.android.launcher3.util.DisplayController;
import com.android.launcher3.util.LauncherLayoutBuilder;
import com.android.launcher3.util.TestUtil;
import com.android.launcher3.util.ui.AbstractLauncherUiTest;
import org.junit.After;
import org.junit.Assume;
@@ -33,6 +33,7 @@ import android.view.ViewGroup.LayoutParams.MATCH_PARENT
import androidx.test.platform.app.InstrumentationRegistry
import com.android.launcher3.AbstractFloatingView
import com.android.launcher3.AbstractFloatingViewHelper
import com.android.launcher3.Flags.enableRefactorTaskContentView
import com.android.launcher3.Flags.enableRefactorTaskThumbnail
import com.android.launcher3.InvariantDeviceProfile
import com.android.launcher3.R
@@ -42,15 +43,18 @@ import com.android.launcher3.logging.StatsLogManager.StatsLogger
import com.android.launcher3.model.data.ItemInfo
import com.android.launcher3.model.data.TaskViewItemInfo
import com.android.launcher3.util.RunnableList
import com.android.launcher3.util.SandboxContext
import com.android.launcher3.util.SplitConfigurationOptions
import com.android.launcher3.util.TransformingTouchDelegate
import com.android.launcher3.util.WindowBounds
import com.android.quickstep.TaskViewTestDIHelpers.initializeRecentsDependencies
import com.android.quickstep.TaskViewTestDIHelpers.mockRecentsModel
import com.android.quickstep.orientation.LandscapePagedViewHandler
import com.android.quickstep.recents.data.RecentsDeviceProfileRepository
import com.android.quickstep.recents.data.RecentsRotationStateRepository
import com.android.quickstep.recents.di.RecentsDependencies
import com.android.quickstep.task.thumbnail.TaskContentView
import com.android.quickstep.task.thumbnail.TaskThumbnailView
import com.android.quickstep.util.RecentsOrientedState
import com.android.quickstep.util.SingleTask
import com.android.quickstep.views.LauncherRecentsView
import com.android.quickstep.views.RecentsViewContainer
import com.android.quickstep.views.TaskContainer
@@ -59,7 +63,6 @@ import com.android.quickstep.views.TaskView
import com.android.quickstep.views.TaskViewIcon
import com.android.systemui.shared.recents.model.Task
import com.android.systemui.shared.recents.model.Task.TaskKey
import com.android.window.flags.Flags
import com.google.common.truth.Truth.assertThat
import org.junit.After
import org.junit.Before
@@ -67,7 +70,6 @@ import org.junit.Rule
import org.junit.Test
import org.mockito.Mockito
import org.mockito.Mockito.eq
import org.mockito.Mockito.isNull
import org.mockito.kotlin.any
import org.mockito.kotlin.argumentCaptor
import org.mockito.kotlin.doReturn
@@ -83,6 +85,7 @@ class AspectRatioSystemShortcutTests {
/** Spy on a concrete Context so we can reference real View, Layout, and Display properties. */
private val context: Context = spy(InstrumentationRegistry.getInstrumentation().targetContext)
private val applicationContext = SandboxContext(context)
/**
* RecentsViewContainer and its super-interface ActivityContext contain methods to convert
@@ -123,9 +126,7 @@ class AspectRatioSystemShortcutTests {
private val statsLogger = mock<StatsLogger>()
private val orientedState: RecentsOrientedState =
mock(defaultAnswer = Mockito.RETURNS_DEEP_STUBS)
private val taskView: TaskView =
LayoutInflater.from(context).cloneInContext(launcher).inflate(R.layout.task, null) as
TaskView
private lateinit var taskView: TaskView
@Before
fun setUp() {
@@ -136,22 +137,17 @@ class AspectRatioSystemShortcutTests {
whenever(statsLogger.withItemInfo(any())).thenReturn(statsLogger)
whenever(orientedState.orientationHandler).thenReturn(LandscapePagedViewHandler())
taskView.setLayoutParams(ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT))
if (enableRefactorTaskThumbnail()) {
val recentsDependencies = RecentsDependencies.maybeInitialize(launcher)
val scopeId = recentsDependencies.createRecentsViewScope(launcher)
recentsDependencies.provide(
RecentsRotationStateRepository::class.java,
scopeId,
{ mock<RecentsRotationStateRepository>() }
)
recentsDependencies.provide(
RecentsDeviceProfileRepository::class.java,
scopeId,
{ mock<RecentsDeviceProfileRepository>() }
applicationContext.initDaggerComponent(
DaggerTaskViewTestComponent.builder().bindRecentsModel(mockRecentsModel())
)
initializeRecentsDependencies(launcher)
}
taskView =
LayoutInflater.from(context).cloneInContext(launcher).inflate(R.layout.task, null)
as TaskView
taskView.setLayoutParams(ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT))
}
@After
@@ -165,14 +161,14 @@ class AspectRatioSystemShortcutTests {
* When the corresponding feature flag is off, there will not be an option to open aspect ratio
* settings.
*/
@DisableFlags(com.android.window.flags.Flags.FLAG_UNIVERSAL_RESIZABLE_BY_DEFAULT)
@DisableFlags(com.android.window.flags2.Flags.FLAG_UNIVERSAL_RESIZABLE_BY_DEFAULT)
@Test
fun createShortcut_flaggedOff_notCreated() {
val task = createTask()
val taskContainer = createTaskContainer(task)
setScreenSizeDp(widthDp = 1200, heightDp = 800)
taskView.bind(task, orientedState, taskOverlayFactory)
taskView.bind(SingleTask(task), orientedState, taskOverlayFactory)
assertThat(factory.getShortcuts(launcher, taskContainer)).isNull()
}
@@ -181,14 +177,14 @@ class AspectRatioSystemShortcutTests {
* When the screen doesn't meet or exceed sw600dp (eg. phone, watch), there will not be an
* option to open aspect ratio settings.
*/
@EnableFlags(com.android.window.flags.Flags.FLAG_UNIVERSAL_RESIZABLE_BY_DEFAULT)
@EnableFlags(com.android.window.flags2.Flags.FLAG_UNIVERSAL_RESIZABLE_BY_DEFAULT)
@Test
fun createShortcut_sw599dp_notCreated() {
val task = createTask()
val taskContainer = createTaskContainer(task)
setScreenSizeDp(widthDp = 599, heightDp = 599)
taskView.bind(task, orientedState, taskOverlayFactory)
taskView.bind(SingleTask(task), orientedState, taskOverlayFactory)
assertThat(factory.getShortcuts(launcher, taskContainer)).isNull()
}
@@ -197,7 +193,7 @@ class AspectRatioSystemShortcutTests {
* When the screen does meet or exceed sw600dp (eg. tablet, inner foldable screen, home cinema)
* there will be an option to open aspect ratio settings.
*/
@EnableFlags(com.android.window.flags.Flags.FLAG_UNIVERSAL_RESIZABLE_BY_DEFAULT)
@EnableFlags(com.android.window.flags2.Flags.FLAG_UNIVERSAL_RESIZABLE_BY_DEFAULT)
@Test
fun createShortcut_sw800dp_created_andOpensSettings() {
val task = createTask()
@@ -206,7 +202,7 @@ class AspectRatioSystemShortcutTests {
doReturn(taskViewItemInfo).whenever(taskContainer).itemInfo
setScreenSizeDp(widthDp = 1200, heightDp = 800)
taskView.bind(task, orientedState, taskOverlayFactory)
taskView.bind(SingleTask(task), orientedState, taskOverlayFactory)
val shortcuts = factory.getShortcuts(launcher, taskContainer)
assertThat(shortcuts).hasSize(1)
@@ -273,6 +269,11 @@ class AspectRatioSystemShortcutTests {
TaskContainer(
taskView,
task,
when {
enableRefactorTaskContentView() -> mock<TaskContentView>()
enableRefactorTaskThumbnail() -> mock<TaskThumbnailView>()
else -> mock<TaskThumbnailViewDeprecated>()
},
if (enableRefactorTaskThumbnail()) mock<TaskThumbnailView>()
else mock<TaskThumbnailViewDeprecated>(),
mock<TaskViewIcon>(),
@@ -16,11 +16,9 @@
package com.android.quickstep
import android.Manifest.permission.SYSTEM_ALERT_WINDOW
import android.content.ComponentName
import android.content.Context
import android.content.Intent
import android.content.pm.PackageInfo
import android.content.pm.PackageManager
import android.platform.test.annotations.DisableFlags
import android.platform.test.annotations.EnableFlags
@@ -32,6 +30,8 @@ import com.android.dx.mockito.inline.extended.StaticMockitoSession
import com.android.internal.R
import com.android.launcher3.AbstractFloatingView
import com.android.launcher3.AbstractFloatingViewHelper
import com.android.launcher3.Flags
import com.android.launcher3.Flags.enableRefactorTaskContentView
import com.android.launcher3.Flags.enableRefactorTaskThumbnail
import com.android.launcher3.logging.StatsLogManager
import com.android.launcher3.logging.StatsLogManager.LauncherEvent
@@ -39,6 +39,7 @@ import com.android.launcher3.model.data.TaskViewItemInfo
import com.android.launcher3.util.SplitConfigurationOptions
import com.android.launcher3.util.TransformingTouchDelegate
import com.android.quickstep.TaskOverlayFactory.TaskOverlay
import com.android.quickstep.task.thumbnail.TaskContentView
import com.android.quickstep.task.thumbnail.TaskThumbnailView
import com.android.quickstep.views.LauncherRecentsView
import com.android.quickstep.views.RecentsViewContainer
@@ -49,16 +50,16 @@ import com.android.quickstep.views.TaskViewIcon
import com.android.quickstep.views.TaskViewType
import com.android.systemui.shared.recents.model.Task
import com.android.systemui.shared.recents.model.Task.TaskKey
import com.android.window.flags.Flags
import com.android.window.flags2.Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MODALS_POLICY
import com.android.wm.shell.shared.desktopmode.DesktopModeStatus
import com.android.wm.shell.shared.desktopmode.DesktopModeTransitionSource
import com.google.common.truth.Truth.assertThat
import kotlin.test.assertIs
import kotlin.test.assertNotNull
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.mockito.ArgumentMatchers.anyInt
import org.mockito.ArgumentMatchers.anyString
import org.mockito.Mockito.`when`
import org.mockito.kotlin.any
import org.mockito.kotlin.doReturn
@@ -97,6 +98,7 @@ class DesktopSystemShortcutTest {
.startMocking()
whenever(DesktopModeStatus.canEnterDesktopMode(any())).thenReturn(true)
whenever(overlayFactory.createOverlay(any())).thenReturn(mock<TaskOverlay<*>>())
doReturn(DEFAULT_DISPLAY).whenever(context).displayId
whenever(launcher.asContext()).thenReturn(context)
}
@@ -116,8 +118,29 @@ class DesktopSystemShortcutTest {
}
@Test
@EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MODALS_POLICY)
@DisableFlags(Flags.FLAG_ENABLE_MODALS_FULLSCREEN_WITH_PERMISSION)
@EnableFlags(FLAG_ENABLE_DESKTOP_WINDOWING_MODALS_POLICY)
fun createDesktopTaskShortcutFactory_noDisplayActivity() {
val baseComponent = ComponentName("", /* class */ "")
val taskKey =
TaskKey(
/* id */ 1,
/* windowingMode */ 0,
Intent(),
baseComponent,
/* userId */ 0,
/* lastActiveTime */ 2000,
DEFAULT_DISPLAY,
baseComponent,
/* numActivities */ 1,
/* isTopActivityNoDisplay */ true,
/* isActivityStackTransparent */ false,
)
val taskContainer = createTaskContainer(Task(taskKey))
val shortcuts = factory.getShortcuts(launcher, taskContainer)
}
@Test
@EnableFlags(FLAG_ENABLE_DESKTOP_WINDOWING_MODALS_POLICY)
fun createDesktopTaskShortcutFactory_transparentTask() {
val baseComponent = ComponentName("", /* class */ "")
val taskKey =
@@ -140,65 +163,7 @@ class DesktopSystemShortcutTest {
}
@Test
@EnableFlags(
Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MODALS_POLICY,
Flags.FLAG_ENABLE_MODALS_FULLSCREEN_WITH_PERMISSION,
)
fun createDesktopTaskShortcutFactoryPermissionEnabledAllowed_transparentTask() {
val packageManager: PackageManager = mock()
setUpTransparentPermission(packageManager, isAllowed = true)
val baseComponent = ComponentName("", /* class */ "")
val taskKey =
TaskKey(
/* id */ 1,
/* windowingMode */ 0,
Intent(),
baseComponent,
/* userId */ 0,
/* lastActiveTime */ 2000,
DEFAULT_DISPLAY,
baseComponent,
/* numActivities */ 1,
/* isTopActivityNoDisplay */ false,
/* isActivityStackTransparent */ true,
)
val taskContainer = createTaskContainer(Task(taskKey))
val shortcuts = factory.getShortcuts(launcher, taskContainer)
assertThat(shortcuts).isNull()
}
@Test
@EnableFlags(
Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MODALS_POLICY,
Flags.FLAG_ENABLE_MODALS_FULLSCREEN_WITH_PERMISSION,
)
fun createDesktopTaskShortcutFactoryPermissionEnabledNotAllowed_transparentTask() {
val packageManager: PackageManager = mock()
setUpTransparentPermission(packageManager, isAllowed = false)
val baseComponent = ComponentName("", /* class */ "")
val homeActivities = ComponentName("defaultHomePackage", /* class */ "")
whenever(packageManager.getHomeActivities(any())).thenReturn(homeActivities)
val taskKey =
TaskKey(
/* id */ 1,
/* windowingMode */ 0,
Intent(),
baseComponent,
/* userId */ 0,
/* lastActiveTime */ 2000,
DEFAULT_DISPLAY,
baseComponent,
/* numActivities */ 1,
/* isTopActivityNoDisplay */ false,
/* isActivityStackTransparent */ true,
)
val taskContainer = createTaskContainer(Task(taskKey).apply { isDockable = true })
val shortcuts = factory.getShortcuts(launcher, taskContainer)
assertThat(shortcuts).isNotEmpty()
}
@Test
@EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MODALS_POLICY)
@EnableFlags(FLAG_ENABLE_DESKTOP_WINDOWING_MODALS_POLICY)
fun createDesktopTaskShortcutFactory_systemUiTask() {
val sysUiPackageName: String = context.resources.getString(R.string.config_systemUi)
val baseComponent = ComponentName(sysUiPackageName, /* class */ "")
@@ -222,7 +187,7 @@ class DesktopSystemShortcutTest {
}
@Test
@EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MODALS_POLICY)
@EnableFlags(FLAG_ENABLE_DESKTOP_WINDOWING_MODALS_POLICY)
fun createDesktopTaskShortcutFactory_defaultHomeTask() {
val packageManager: PackageManager = mock()
whenever(context.packageManager).thenReturn(packageManager)
@@ -257,10 +222,11 @@ class DesktopSystemShortcutTest {
}
@Test
fun desktopSystemShortcutClicked() {
fun desktopSystemShortcutClickedWithoutDesktopModeOnDisplay() {
val task = createTask()
val taskContainer = spy(createTaskContainer(task))
whenever(DesktopModeStatus.isDesktopModeSupportedOnDisplay(any(), any())).thenReturn(false)
whenever(launcher.getOverviewPanel<LauncherRecentsView>()).thenReturn(recentsView)
whenever(launcher.statsLogManager).thenReturn(statsLogManager)
whenever(statsLogManager.logger()).thenReturn(statsLogger)
@@ -274,10 +240,29 @@ class DesktopSystemShortcutTest {
doReturn(taskViewItemInfo).whenever(taskContainer).itemInfo
val shortcuts = factory.getShortcuts(launcher, taskContainer)
assertThat(shortcuts).isNotNull()
assertThat(shortcuts!!.single()).isInstanceOf(DesktopSystemShortcut::class.java)
assertThat(shortcuts).isNull()
}
val desktopShortcut = shortcuts.single() as DesktopSystemShortcut
@Test
fun desktopSystemShortcutClickedWithDesktopModeOnDisplay() {
val task = createTask()
val taskContainer = spy(createTaskContainer(task))
whenever(DesktopModeStatus.isDesktopModeSupportedOnDisplay(any(), any())).thenReturn(true)
whenever(launcher.getOverviewPanel<LauncherRecentsView>()).thenReturn(recentsView)
whenever(launcher.statsLogManager).thenReturn(statsLogManager)
whenever(statsLogManager.logger()).thenReturn(statsLogger)
whenever(statsLogger.withItemInfo(any())).thenReturn(statsLogger)
whenever(taskView.context).thenReturn(context)
whenever(recentsView.moveTaskToDesktop(any(), any(), any())).thenAnswer {
val successCallback = it.getArgument<Runnable>(2)
successCallback.run()
}
val taskViewItemInfo = mock<TaskViewItemInfo>()
doReturn(taskViewItemInfo).whenever(taskContainer).itemInfo
val shortcuts = assertNotNull(factory.getShortcuts(launcher, taskContainer))
val desktopShortcut = assertIs<DesktopSystemShortcut>(shortcuts.single())
desktopShortcut.onClick(taskView)
@@ -294,7 +279,20 @@ class DesktopSystemShortcutTest {
verify(statsLogger).log(LauncherEvent.LAUNCHER_SYSTEM_SHORTCUT_DESKTOP_TAP)
}
private fun createTask() =
@Test
@DisableFlags(Flags.FLAG_ENABLE_DESKTOP_MENU_ON_SECONDARY_DISPLAY_BUGFIX)
fun createDesktopTaskShortcutFactoryOnSecondaryDisplayWithoutFlag() {
`when`(DesktopModeStatus.canEnterDesktopMode(any())).thenReturn(true)
`when`(DesktopModeStatus.isDesktopModeSupportedOnDisplay(any(), any())).thenReturn(true)
doReturn(SECONDARY_DISPLAY).whenever(context).displayId
val taskContainer = createTaskContainer(createTask(displayId = SECONDARY_DISPLAY))
val shortcuts = factory.getShortcuts(launcher, taskContainer)
assertThat(shortcuts).isNull()
}
private fun createTask(displayId: Int = DEFAULT_DISPLAY) =
Task(
TaskKey(
/* id */ 1,
@@ -303,7 +301,7 @@ class DesktopSystemShortcutTest {
ComponentName("", ""),
/* userId */ 0,
/* lastActiveTime */ 2000,
DEFAULT_DISPLAY,
displayId,
ComponentName("", ""),
/* numActivities */ 1,
/* isTopActivityNoDisplay */ false,
@@ -316,6 +314,11 @@ class DesktopSystemShortcutTest {
TaskContainer(
taskView,
task,
when {
enableRefactorTaskContentView() -> mock<TaskContentView>()
enableRefactorTaskThumbnail() -> mock<TaskThumbnailView>()
else -> mock<TaskThumbnailViewDeprecated>()
},
if (enableRefactorTaskThumbnail()) mock<TaskThumbnailView>()
else mock<TaskThumbnailViewDeprecated>(),
mock<TaskViewIcon>(),
@@ -326,26 +329,14 @@ class DesktopSystemShortcutTest {
overlayFactory,
)
private fun setUpTransparentPermission(packageManager: PackageManager, isAllowed: Boolean) {
val packageInfo: PackageInfo = mock()
if (isAllowed) {
packageInfo.requestedPermissions = arrayOf(SYSTEM_ALERT_WINDOW)
}
whenever(context.packageManager).thenReturn(packageManager)
whenever(
packageManager.getPackageInfoAsUser(
anyString(),
eq(PackageManager.GET_PERMISSIONS),
anyInt(),
)
)
.thenReturn(packageInfo)
}
private fun createTaskViewMock(): TaskView {
val taskView: TaskView = mock()
whenever(taskView.type).thenReturn(TaskViewType.SINGLE)
whenever(taskView.context).thenReturn(context)
return taskView
}
private companion object {
const val SECONDARY_DISPLAY = 13
}
}
@@ -15,24 +15,33 @@
*/
package com.android.quickstep;
import static androidx.test.InstrumentationRegistry.getInstrumentation;
import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
import static com.android.launcher3.util.TestUtil.resolveSystemAppInfo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import android.app.PendingIntent;
import android.app.usage.UsageStatsManager;
import android.content.Intent;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.LargeTest;
import androidx.test.runner.AndroidJUnit4;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
import com.android.launcher3.uioverrides.QuickstepLauncher;
import com.android.launcher3.util.BaseLauncherActivityTest;
import com.android.launcher3.util.rule.ScreenRecordRule;
import com.android.quickstep.views.DigitalWellBeingToast;
import com.android.quickstep.views.RecentsView;
import com.android.quickstep.views.TaskContainer;
import com.android.quickstep.views.TaskView;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -40,41 +49,50 @@ import java.time.Duration;
@LargeTest
@RunWith(AndroidJUnit4.class)
public class TaplDigitalWellBeingToastTest extends AbstractQuickStepTest {
private static final String CALCULATOR_PACKAGE =
resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR);
public class DigitalWellBeingToastTest extends BaseLauncherActivityTest<QuickstepLauncher> {
@Rule
public ScreenRecordRule mScreenRecordRule = new ScreenRecordRule();
public final String calculatorPackage =
resolveSystemAppInfo(Intent.CATEGORY_APP_CALCULATOR).packageName;
@Test
public void testToast() throws Exception {
startAppFast(CALCULATOR_PACKAGE);
public void testToast() {
startAppFast(calculatorPackage);
final UsageStatsManager usageStatsManager =
mTargetContext.getSystemService(UsageStatsManager.class);
targetContext().getSystemService(UsageStatsManager.class);
final int observerId = 0;
try {
final String[] packages = new String[]{CALCULATOR_PACKAGE};
final String[] packages = new String[]{calculatorPackage};
// Set time limit for app.
runWithShellPermission(() ->
usageStatsManager.registerAppUsageLimitObserver(observerId, packages,
Duration.ofSeconds(600), Duration.ofSeconds(300),
PendingIntent.getActivity(mTargetContext, -1, new Intent()
.setPackage(mTargetContext.getPackageName()),
PendingIntent.getActivity(targetContext(), -1, new Intent()
.setPackage(targetContext().getPackageName()),
PendingIntent.FLAG_MUTABLE)));
mLauncher.goHome();
// b/324261526 when removing BaseLauncherActivityTest we should be able to tell test
// by test test if they should start the activity from the start or wait, and that
// should get rid of this.
getLauncherActivity().close();
loadLauncherSync();
final DigitalWellBeingToast toast = getToast();
waitForLauncherCondition("Toast is not visible", launcher -> toast.hasLimit());
assertEquals("Toast text: ", "5 minutes left today", toast.getText());
waitForLauncherCondition("Toast is not visible", launcher -> toast.getHasLimit());
assertEquals("Toast text: ", "5 minutes left today", toast.getBannerText());
// Unset time limit for app.
runWithShellPermission(
() -> usageStatsManager.unregisterAppUsageLimitObserver(observerId));
mLauncher.goHome();
assertFalse("Toast is visible", getToast().hasLimit());
getLauncherActivity().goToState(LauncherState.NORMAL);
assertFalse("Toast is visible", getToast().getHasLimit());
} finally {
runWithShellPermission(
() -> usageStatsManager.unregisterAppUsageLimitObserver(observerId));
@@ -82,19 +100,23 @@ public class TaplDigitalWellBeingToastTest extends AbstractQuickStepTest {
}
private DigitalWellBeingToast getToast() {
mLauncher.getWorkspace().switchToOverview();
final TaskView task = getOnceNotNull("No latest task", launcher -> getLatestTask(launcher));
getLauncherActivity().goToState(LauncherState.OVERVIEW);
final TaskView task = getLauncherActivity().getOnceNotNull(
"No latest task",
launcher -> getLatestTask(launcher)
);
return getFromLauncher(launcher -> {
TaskView.TaskContainer taskContainer = task.getTaskContainers().get(0);
assertTrue("Latest task is not Calculator", CALCULATOR_PACKAGE.equals(
return getLauncherActivity().getFromLauncher(launcher -> {
TaskContainer taskContainer = task.getFirstTaskContainer();
assertNotNull(taskContainer);
assertTrue("Latest task is not Calculator", calculatorPackage.equals(
taskContainer.getTask().getTopComponent().getPackageName()));
return taskContainer.getDigitalWellBeingToast();
});
}
private TaskView getLatestTask(Launcher launcher) {
return launcher.<RecentsView>getOverviewPanel().getTaskViewAt(0);
return launcher.<RecentsView>getOverviewPanel().getFirstTaskView();
}
private void runWithShellPermission(Runnable action) {
@@ -104,6 +126,5 @@ public class TaplDigitalWellBeingToastTest extends AbstractQuickStepTest {
} finally {
getInstrumentation().getUiAutomation().dropShellPermissionIdentity();
}
}
}
@@ -20,7 +20,6 @@ import android.content.ComponentName
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.platform.test.annotations.DisableFlags
import android.platform.test.annotations.EnableFlags
import android.platform.test.flag.junit.SetFlagsRule
import android.view.Display.DEFAULT_DISPLAY
@@ -30,6 +29,7 @@ import com.android.dx.mockito.inline.extended.StaticMockitoSession
import com.android.internal.R
import com.android.launcher3.AbstractFloatingView
import com.android.launcher3.AbstractFloatingViewHelper
import com.android.launcher3.Flags.enableRefactorTaskContentView
import com.android.launcher3.Flags.enableRefactorTaskThumbnail
import com.android.launcher3.logging.StatsLogManager
import com.android.launcher3.logging.StatsLogManager.LauncherEvent
@@ -37,6 +37,7 @@ import com.android.launcher3.model.data.TaskViewItemInfo
import com.android.launcher3.util.SplitConfigurationOptions
import com.android.launcher3.util.TransformingTouchDelegate
import com.android.quickstep.TaskOverlayFactory.TaskOverlay
import com.android.quickstep.task.thumbnail.TaskContentView
import com.android.quickstep.task.thumbnail.TaskThumbnailView
import com.android.quickstep.views.LauncherRecentsView
import com.android.quickstep.views.RecentsViewContainer
@@ -46,7 +47,7 @@ import com.android.quickstep.views.TaskView
import com.android.quickstep.views.TaskViewIcon
import com.android.systemui.shared.recents.model.Task
import com.android.systemui.shared.recents.model.Task.TaskKey
import com.android.window.flags.Flags
import com.android.window.flags2.Flags
import com.android.wm.shell.shared.desktopmode.DesktopModeStatus
import com.google.common.truth.Truth.assertThat
import org.junit.After
@@ -114,7 +115,32 @@ class ExternalDisplaySystemShortcutTest {
Flags.FLAG_MOVE_TO_EXTERNAL_DISPLAY_SHORTCUT,
Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MODALS_POLICY,
)
@DisableFlags(Flags.FLAG_ENABLE_MODALS_FULLSCREEN_WITH_PERMISSION)
fun createExternalDisplayTaskShortcut_noDisplayActivity() {
val baseComponent = ComponentName("", /* class */ "")
val taskKey =
TaskKey(
/* id */ 1,
/* windowingMode */ 0,
Intent(),
baseComponent,
/* userId */ 0,
/* lastActiveTime */ 2000,
DEFAULT_DISPLAY,
baseComponent,
/* numActivities */ 1,
/* isTopActivityNoDisplay */ true,
/* isActivityStackTransparent */ false,
)
val taskContainer = createTaskContainer(Task(taskKey))
val shortcuts = factory.getShortcuts(launcher, taskContainer)
assertThat(shortcuts).isNull()
}
@Test
@EnableFlags(
Flags.FLAG_MOVE_TO_EXTERNAL_DISPLAY_SHORTCUT,
Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MODALS_POLICY,
)
fun createExternalDisplayTaskShortcut_transparentTask() {
val baseComponent = ComponentName("", /* class */ "")
val taskKey =
@@ -246,6 +272,11 @@ class ExternalDisplaySystemShortcutTest {
TaskContainer(
taskView,
task,
when {
enableRefactorTaskContentView() -> mock<TaskContentView>()
enableRefactorTaskThumbnail() -> mock<TaskThumbnailView>()
else -> mock<TaskThumbnailViewDeprecated>()
},
if (enableRefactorTaskThumbnail()) mock<TaskThumbnailView>()
else mock<TaskThumbnailViewDeprecated>(),
mock<TaskViewIcon>(),
@@ -16,21 +16,21 @@
package com.android.quickstep;
import static android.content.pm.PackageManager.MATCH_DISABLED_COMPONENTS;
import static android.view.Display.DEFAULT_DISPLAY;
import static androidx.test.InstrumentationRegistry.getInstrumentation;
import static com.android.launcher3.Flags.enableFallbackOverviewInWindow;
import static com.android.launcher3.tapl.LauncherInstrumentation.WAIT_TIME_MS;
import static com.android.launcher3.tapl.TestHelpers.getHomeIntentInPackage;
import static com.android.launcher3.tapl.TestHelpers.getLauncherInMyProcess;
import static com.android.launcher3.ui.AbstractLauncherUiTest.DEFAULT_BROADCAST_TIMEOUT_SECS;
import static com.android.launcher3.ui.AbstractLauncherUiTest.resolveSystemApp;
import static com.android.launcher3.ui.AbstractLauncherUiTest.startAppFast;
import static com.android.launcher3.ui.AbstractLauncherUiTest.startTestActivity;
import static com.android.launcher3.ui.TaplTestsLauncher3Test.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.ui.AbstractLauncherUiTest.DEFAULT_BROADCAST_TIMEOUT_SECS;
import static com.android.launcher3.util.ui.AbstractLauncherUiTest.resolveSystemApp;
import static com.android.launcher3.util.ui.AbstractLauncherUiTest.startAppFast;
import static com.android.launcher3.util.ui.AbstractLauncherUiTest.startTestActivity;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -41,6 +41,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.RemoteException;
import android.platform.test.rule.ExtendedLongPressTimeoutRule;
import androidx.test.filters.LargeTest;
import androidx.test.runner.AndroidJUnit4;
@@ -54,17 +55,17 @@ import com.android.launcher3.tapl.LauncherInstrumentation;
import com.android.launcher3.tapl.OverviewTask;
import com.android.launcher3.tapl.TestHelpers;
import com.android.launcher3.testcomponent.TestCommandReceiver;
import com.android.launcher3.ui.AbstractLauncherUiTest;
import com.android.launcher3.util.TestUtil;
import com.android.launcher3.util.Wait;
import com.android.launcher3.util.rule.ExtendedLongPressTimeoutRule;
import com.android.launcher3.util.rule.FailureWatcher;
import com.android.launcher3.util.rule.SamplerRule;
import com.android.launcher3.util.rule.ScreenRecordRule;
import com.android.launcher3.util.rule.SkipAfterTimeOutRule;
import com.android.launcher3.util.rule.TestIsolationRule;
import com.android.launcher3.util.rule.TestStabilityRule;
import com.android.launcher3.util.rule.ViewCaptureRule;
import com.android.launcher3.util.ui.AbstractLauncherUiTest;
import com.android.quickstep.OverviewComponentObserver.OverviewChangeListener;
import com.android.quickstep.fallback.window.RecentsWindowFlags;
import com.android.quickstep.fallback.window.RecentsWindowManager;
import com.android.quickstep.views.RecentsView;
import com.android.quickstep.views.RecentsViewContainer;
@@ -110,6 +111,9 @@ public class FallbackRecentsTest {
@Rule
public ExtendedLongPressTimeoutRule mLongPressTimeoutRule = new ExtendedLongPressTimeoutRule();
@Rule(order = -1000) // This should be the outermost rule
public SkipAfterTimeOutRule mSkipAfterTimeOutRule = new SkipAfterTimeOutRule();
public FallbackRecentsTest() throws RemoteException {
Instrumentation instrumentation = getInstrumentation();
Context context = instrumentation.getContext();
@@ -132,6 +136,7 @@ public class FallbackRecentsTest {
getLauncherCommand(mOtherLauncherActivity));
updateHandler.mChangeCounter
.await(DEFAULT_BROADCAST_TIMEOUT_SECS, TimeUnit.SECONDS);
mLauncher.setTestLauncherPackage(mOtherLauncherActivity.packageName);
try {
base.evaluate();
} finally {
@@ -139,19 +144,17 @@ public class FallbackRecentsTest {
TestCommandReceiver.callCommand(TestCommandReceiver.DISABLE_TEST_LAUNCHER);
UiDevice.getInstance(getInstrumentation()).executeShellCommand(
getLauncherCommand(getLauncherInMyProcess()));
mLauncher.setTestLauncherPackage(null);
pressHomeAndWaitForOverviewClose();
}
}
};
final ViewCaptureRule viewCaptureRule = new ViewCaptureRule(
RecentsActivity.ACTIVITY_TRACKER::getCreatedContext);
mOrderSensitiveRules = RuleChain
.outerRule(new SamplerRule())
.around(new TestStabilityRule())
.around(new NavigationModeSwitchRule(mLauncher))
.around(new FailureWatcher(mLauncher, viewCaptureRule::getViewCaptureData))
// .around(viewCaptureRule) b/315482167
.around(new FailureWatcher(mLauncher))
.around(new TestIsolationRule(mLauncher, false))
.around(setLauncherCommand);
@@ -211,9 +214,10 @@ public class FallbackRecentsTest {
if (!TestHelpers.isInLauncherProcess()) return null;
Object[] result = new Object[1];
Wait.atMost("Failed to get from recents", () -> MAIN_EXECUTOR.submit(() -> {
RecentsViewContainer recentsViewContainer = enableFallbackOverviewInWindow()
? RecentsWindowManager.getRecentsWindowTracker().getCreatedContext()
: RecentsActivity.ACTIVITY_TRACKER.getCreatedContext();
RecentsViewContainer recentsViewContainer =
RecentsWindowFlags.enableFallbackOverviewInWindow.isTrue()
? RecentsWindowManager.getRecentsWindowTracker().getCreatedContext()
: RecentsActivity.ACTIVITY_TRACKER.getCreatedContext();
if (recentsViewContainer == null) {
return false;
}
@@ -236,9 +240,10 @@ public class FallbackRecentsTest {
private void waitForRecentsClosed() {
try {
final boolean isRecentsContainerNUll = MAIN_EXECUTOR.submit(() -> {
RecentsViewContainer recentsViewContainer = enableFallbackOverviewInWindow()
? RecentsWindowManager.getRecentsWindowTracker().getCreatedContext()
: RecentsActivity.ACTIVITY_TRACKER.getCreatedContext();
RecentsViewContainer recentsViewContainer =
RecentsWindowFlags.enableFallbackOverviewInWindow.isTrue()
? RecentsWindowManager.getRecentsWindowTracker().getCreatedContext()
: RecentsActivity.ACTIVITY_TRACKER.getCreatedContext();
return recentsViewContainer == null;
}).get();
@@ -340,7 +345,7 @@ public class FallbackRecentsTest {
Context ctx = getInstrumentation().getTargetContext();
mObserver = OverviewComponentObserver.INSTANCE.get(ctx);
mChangeCounter = new CountDownLatch(1);
if (mObserver.getHomeIntent().getComponent()
if (mObserver.getHomeIntent(DEFAULT_DISPLAY).getComponent()
.getPackageName().equals(mOtherLauncherActivity.packageName)) {
// Home already same
mChangeCounter.countDown();
@@ -55,6 +55,7 @@ import com.android.launcher3.taskbar.bubbles.BubbleDismissController;
import com.android.launcher3.taskbar.bubbles.BubbleDragController;
import com.android.launcher3.taskbar.bubbles.BubblePinController;
import com.android.launcher3.taskbar.bubbles.BubbleStashedHandleViewController;
import com.android.launcher3.taskbar.bubbles.DragToBubbleController;
import com.android.launcher3.taskbar.bubbles.stashing.BubbleStashController;
import com.android.launcher3.util.LockedUserState;
import com.android.launcher3.util.SandboxApplication;
@@ -113,6 +114,7 @@ public class InputConsumerUtilsTest {
@NonNull @Mock private TaskbarActivityContext mTaskbarActivityContext;
@NonNull @Mock private OverviewComponentObserver mOverviewComponentObserver;
@NonNull @Mock private RecentsAnimationDeviceState mDeviceState;
@NonNull @Mock private RotationTouchHelper mRotationTouchHelper;
@NonNull @Mock private AbsSwipeUpHandler.Factory mSwipeUpHandlerFactory;
@NonNull @Mock private TaskbarManager mTaskbarManager;
@NonNull @Mock private OverviewCommandHelper mOverviewCommandHelper;
@@ -128,7 +130,7 @@ public class InputConsumerUtilsTest {
@Before
public void setupTaskAnimationManager() {
mTaskAnimationManager = new TaskAnimationManager(mContext, mDeviceState, mDisplayId);
mTaskAnimationManager = new TaskAnimationManager(mContext, mDisplayId);
}
@Before
@@ -136,8 +138,7 @@ public class InputConsumerUtilsTest {
mContext.initDaggerComponent(DaggerInputConsumerUtilsTest_TestComponent
.builder()
.bindLockedState(mLockedUserState)
.bindRotationHelper(mock(RotationTouchHelper.class))
.bindRecentsState(mDeviceState));
);
}
@Before
@@ -201,8 +202,10 @@ public class InputConsumerUtilsTest {
@After
public void cleanUp() {
mInputMonitorCompat.dispose();
mInputEventReceiver.dispose();
runOnMainSync(() -> {
mInputMonitorCompat.dispose();
mInputEventReceiver.dispose();
});
}
@Test
@@ -295,7 +298,8 @@ public class InputConsumerUtilsTest {
@Test
public void testNewBaseConsumer_launcherChildActivityResumed_returnsDefaultInputConsumer() {
when(mRunningTask.isHomeTask()).thenReturn(true);
when(mOverviewComponentObserver.isHomeAndOverviewSameActivity()).thenReturn(true);
when(mOverviewComponentObserver.isHomeAndOverviewSame()).thenReturn(true);
when(mContainerInterface.isLauncherOverlayShowing()).thenReturn(true);
assertEqualsDefaultInputConsumer(this::createBaseInputConsumer);
}
@@ -502,7 +506,8 @@ public class InputConsumerUtilsTest {
mTaskbarManager,
mSwipeUpProxyProvider,
mOverviewCommandHelper,
event);
event,
mRotationTouchHelper);
event.recycle();
@@ -525,7 +530,8 @@ public class InputConsumerUtilsTest {
otherActivityInputConsumer -> {},
mInputEventReceiver,
event,
ActiveGestureLog.CompoundString.NO_OP);
ActiveGestureLog.CompoundString.NO_OP,
mRotationTouchHelper);
event.recycle();
@@ -597,6 +603,7 @@ public class InputConsumerUtilsTest {
BubbleBarPinController bubbleBarPinController = mock(BubbleBarPinController.class);
BubblePinController bubblePinController = mock(BubblePinController.class);
BubbleBarSwipeController bubbleBarSwipeController = mock(BubbleBarSwipeController.class);
DragToBubbleController dragToBubbleController = mock(DragToBubbleController.class);
BubbleCreator bubbleCreator = mock(BubbleCreator.class);
BubbleControllers bubbleControllers = new BubbleControllers(
bubbleBarController,
@@ -608,6 +615,7 @@ public class InputConsumerUtilsTest {
bubbleBarPinController,
bubblePinController,
Optional.of(bubbleBarSwipeController),
dragToBubbleController,
bubbleCreator);
when(bubbleBarViewController.hasBubbles()).thenReturn(true);
@@ -625,8 +633,6 @@ public class InputConsumerUtilsTest {
@Component.Builder
interface Builder extends LauncherAppComponent.Builder {
@BindsInstance Builder bindLockedState(LockedUserState state);
@BindsInstance Builder bindRotationHelper(RotationTouchHelper helper);
@BindsInstance Builder bindRecentsState(RecentsAnimationDeviceState state);
@Override
TestComponent build();
@@ -33,10 +33,10 @@ import androidx.test.uiautomator.UiDevice;
import com.android.launcher3.tapl.LauncherInstrumentation;
import com.android.launcher3.tapl.TestHelpers;
import com.android.launcher3.ui.AbstractLauncherUiTest;
import com.android.launcher3.util.DisplayController;
import com.android.launcher3.util.Wait;
import com.android.launcher3.util.rule.FailureWatcher;
import com.android.launcher3.util.ui.AbstractLauncherUiTest;
import com.android.systemui.shared.system.QuickStepContract;
import org.junit.rules.TestRule;
@@ -205,12 +205,16 @@ public class NavigationModeSwitchRule implements TestRule {
private static void assertTrue(LauncherInstrumentation launcher, String message,
boolean condition, Description description) {
launcher.checkForAnomaly(true, true);
if (!condition) {
try {
launcher.checkForAnomaly(true, true);
if (!condition) {
throw new AssertionError(message);
}
} catch (Throwable e) {
if (description != null) {
FailureWatcher.onError(launcher, description);
}
throw new AssertionError(message);
throw e;
}
}
}
@@ -339,7 +339,8 @@ public class OrientationTouchTransformerTest {
ArrayMap<CachedDisplayInfo, List<WindowBounds>> internalDisplayBounds = new ArrayMap<>();
doReturn(internalDisplayBounds).when(wmProxy).estimateInternalDisplayBounds(any());
return new DisplayController.Info(
getApplicationContext(), wmProxy, new ArrayMap<>());
getApplicationContext(), false, wmProxy, new ArrayMap<>(),
DisplayMetrics.DENSITY_DEFAULT);
}
private float generateTouchRegionHeight(Size screenSize, int rotation) {
@@ -24,8 +24,6 @@ import android.platform.test.annotations.PlatinumTest;
import com.android.launcher3.tapl.Overview;
import com.android.launcher3.tapl.OverviewTask.OverviewTaskContainer;
import com.android.launcher3.tapl.OverviewTaskMenu;
import com.android.launcher3.ui.AbstractLauncherUiTest;
import com.android.launcher3.uioverrides.QuickstepLauncher;
import com.android.quickstep.util.SplitScreenTestUtils;
import org.junit.Test;
@@ -34,7 +32,7 @@ import org.junit.Test;
* This test run in both Out of process (Oop) and in-process (Ipc).
* Tests the app Icon in overview.
*/
public class TaplOverviewIconTest extends AbstractLauncherUiTest<QuickstepLauncher> {
public class TaplOverviewIconTest extends AbstractQuickStepTest {
private static final String CALCULATOR_APP_PACKAGE =
resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR);
@@ -16,11 +16,13 @@
package com.android.quickstep;
import android.content.Intent;
import android.platform.test.annotations.DisableFlags;
import androidx.annotation.NonNull;
import androidx.test.filters.LargeTest;
import androidx.test.runner.AndroidJUnit4;
import com.android.launcher3.Flags;
import com.android.launcher3.tapl.KeyboardQuickSwitch;
import com.android.launcher3.taskbar.KeyboardQuickSwitchController;
@@ -86,6 +88,7 @@ public class TaplTestsKeyboardQuickSwitch extends AbstractQuickStepTest {
}
@Test
@DisableFlags(value = Flags.FLAG_ENABLE_WIDGET_PICKER_REFACTOR)
public void testDismiss_fromWidgets() {
runTest(TestSurface.WIDGETS, TestCase.DISMISS);
}
@@ -106,6 +109,7 @@ public class TaplTestsKeyboardQuickSwitch extends AbstractQuickStepTest {
}
@Test
@DisableFlags(value = Flags.FLAG_ENABLE_WIDGET_PICKER_REFACTOR)
public void testLaunchLastTask_fromWidgets() {
runTest(TestSurface.WIDGETS, TestCase.LAUNCH_LAST_APP);
}
@@ -126,6 +130,7 @@ public class TaplTestsKeyboardQuickSwitch extends AbstractQuickStepTest {
}
@Test
@DisableFlags(value = Flags.FLAG_ENABLE_WIDGET_PICKER_REFACTOR)
public void testLaunchSelectedTask_fromWidgets() {
runTest(TestSurface.WIDGETS, TestCase.LAUNCH_SELECTED_APP);
}
@@ -146,13 +151,14 @@ public class TaplTestsKeyboardQuickSwitch extends AbstractQuickStepTest {
}
@Test
@DisableFlags(value = Flags.FLAG_ENABLE_WIDGET_PICKER_REFACTOR)
public void testLaunchOverviewTask_fromWidgets() {
runTest(TestSurface.WIDGETS, TestCase.LAUNCH_OVERVIEW);
}
@Test
public void testLaunchSingleRecentTask() {
mLauncher.getLaunchedAppState().switchToOverview().dismissAllTasks();
clearAllRecentTasks();
startAppFast(CALCULATOR_APP_PACKAGE);
mLauncher.goHome().showQuickSwitchView().launchFocusedAppTask(CALCULATOR_APP_PACKAGE);
}
@@ -35,11 +35,11 @@ import androidx.test.filters.LargeTest;
import androidx.test.runner.AndroidJUnit4;
import com.android.launcher3.tapl.HomeAllApps;
import com.android.launcher3.ui.PortraitLandscapeRunner.PortraitLandscape;
import com.android.launcher3.util.rule.SetPropRule;
import com.android.launcher3.util.ui.PortraitLandscapeRunner.PortraitLandscape;
import com.android.quickstep.NavigationModeSwitchRule.NavigationModeSwitch;
import com.android.quickstep.TaskbarModeSwitchRule.TaskbarModeSwitch;
import com.android.window.flags.Flags;
import com.android.window.flags2.Flags;
import com.android.wm.shell.shared.desktopmode.DesktopModeStatus;
import org.junit.Assume;
@@ -23,10 +23,8 @@ import androidx.test.uiautomator.Until
import com.android.launcher3.BuildConfig
import com.android.launcher3.tapl.LaunchedAppState
import com.android.launcher3.tapl.OverviewTask
import com.android.launcher3.ui.AbstractLauncherUiTest
import com.android.launcher3.ui.PortraitLandscapeRunner.PortraitLandscape
import com.android.launcher3.uioverrides.QuickstepLauncher
import com.android.launcher3.util.TestUtil
import com.android.launcher3.util.ui.PortraitLandscapeRunner.PortraitLandscape
import com.google.common.truth.Truth.assertWithMessage
import org.junit.Before
import org.junit.Test
@@ -34,13 +32,10 @@ import org.junit.Test
/** Test Desktop windowing in Overview. */
@AllowedDevices(allowed = [DeviceProduct.CF_TABLET, DeviceProduct.TANGORPRO])
@IgnoreLimit(ignoreLimit = BuildConfig.IS_STUDIO_BUILD)
class TaplTestsOverviewDesktop : AbstractLauncherUiTest<QuickstepLauncher?>() {
class TaplTestsOverviewDesktop : AbstractQuickStepTest() {
@Before
fun setup() {
val overview = mLauncher.goHome().switchToOverview()
if (overview.hasTasks()) {
overview.dismissAllTasks()
}
clearAllRecentTasks()
startTestAppsWithCheck()
mLauncher.goHome()
}
@@ -16,9 +16,6 @@
package com.android.quickstep;
import static com.android.launcher3.Flags.enableLauncherOverviewInWindow;
import static com.android.launcher3.util.rule.TestStabilityRule.LOCAL;
import static com.android.launcher3.util.rule.TestStabilityRule.PLATFORM_POSTSUBMIT;
import static com.android.quickstep.TaskbarModeSwitchRule.Mode.TRANSIENT;
import static org.junit.Assert.assertEquals;
@@ -31,6 +28,7 @@ import static org.junit.Assume.assumeTrue;
import android.content.Intent;
import android.content.res.Configuration;
import android.platform.test.annotations.EnableFlags;
import androidx.annotation.NonNull;
import androidx.test.filters.LargeTest;
@@ -39,6 +37,7 @@ import androidx.test.runner.AndroidJUnit4;
import androidx.test.uiautomator.By;
import androidx.test.uiautomator.Until;
import com.android.launcher3.Flags;
import com.android.launcher3.LauncherState;
import com.android.launcher3.tapl.BaseOverview;
import com.android.launcher3.tapl.LaunchedAppState;
@@ -48,25 +47,20 @@ import com.android.launcher3.tapl.OverviewActions;
import com.android.launcher3.tapl.OverviewTask;
import com.android.launcher3.tapl.SelectModeButtons;
import com.android.launcher3.tapl.Workspace;
import com.android.launcher3.ui.PortraitLandscapeRunner.PortraitLandscape;
import com.android.launcher3.util.TestUtil;
import com.android.launcher3.util.Wait;
import com.android.launcher3.util.rule.ScreenRecordRule;
import com.android.launcher3.util.rule.TestStabilityRule;
import com.android.launcher3.util.ui.PortraitLandscapeRunner.PortraitLandscape;
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;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.util.Comparator;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.Optional;
@LargeTest
@RunWith(AndroidJUnit4.class)
@@ -77,32 +71,17 @@ 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();
runOnRecentsView(recentsView ->
executeOnOverview(recentsView ->
recentsView.getPagedViewOrientedState().forceAllowRotationForTesting(true));
}
@After
public void tearDown() {
runOnRecentsView(recentsView ->
recentsView.getPagedViewOrientedState().forceAllowRotationForTesting(false),
/* forTearDown= */ true);
executeOnOverview(/* forTearDown= */ true, recentsView ->
recentsView.getPagedViewOrientedState().forceAllowRotationForTesting(false));
}
public static void startTestApps() throws Exception {
@@ -128,24 +107,26 @@ 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);
runOnRecentsView(recentsView -> assertTrue("Don't have at least 3 tasks",
"Launcher internal state didn't switch to Overview", LauncherState.OVERVIEW);
executeOnOverview(recentsView -> assertTrue("Don't have at least 3 tasks",
recentsView.getTaskViewCount() >= 3));
// Test flinging forward and backward.
runOnRecentsView(recentsView -> assertEquals("Current task in Overview is not 0",
0, recentsView.getCurrentPage()));
executeOnOverview(recentsView -> assertEquals("Current task in Overview is not first",
recentsView.indexOfChild(recentsView.getFirstTaskView()),
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));
getFromOverview(RecentsView::getCurrentPage);
executeOnOverview(recentsView -> assertTrue("Current task in Overview is still 0",
currentTaskAfterFlingForward > recentsView.indexOfChild(
recentsView.getFirstTaskView())));
overview.flingBackward();
assertIsInState("Launcher internal state is not Overview", ExpectedState.OVERVIEW);
runOnRecentsView(recentsView -> assertTrue("Flinging back in Overview did nothing",
assertIsInState("Launcher internal state is not Overview", LauncherState.OVERVIEW);
executeOnOverview(recentsView -> assertTrue("Flinging back in Overview did nothing",
recentsView.getCurrentPage() < currentTaskAfterFlingForward));
// Test opening a task.
@@ -160,19 +141,19 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
// Test dismissing a task.
overview = mLauncher.goHome().switchToOverview();
assertIsInState("Launcher internal state didn't switch to Overview",
ExpectedState.OVERVIEW);
final Integer numTasks = getFromRecentsView(RecentsView::getTaskViewCount);
LauncherState.OVERVIEW);
final Integer numTasks = getFromOverview(RecentsView::getTaskViewCount);
task = overview.getCurrentTask();
assertNotNull("overview.getCurrentTask() returned null (2)", task);
task.dismiss();
runOnRecentsView(recentsView -> assertEquals(
executeOnOverview(recentsView -> assertEquals(
"Dismissing a task didn't remove 1 task from Overview",
numTasks - 1, recentsView.getTaskViewCount()));
// Test dismissing all tasks.
mLauncher.goHome().switchToOverview().dismissAllTasks();
assertIsInState("Launcher internal state is not Home", ExpectedState.HOME);
runOnRecentsView(recentsView -> assertEquals("Still have tasks after dismissing all",
assertIsInState("Launcher internal state is not Home", LauncherState.NORMAL);
executeOnOverview(recentsView -> assertEquals("Still have tasks after dismissing all",
0, recentsView.getTaskViewCount()));
}
@@ -195,10 +176,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
@@ -214,14 +195,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
@@ -229,11 +211,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.
}
@@ -242,11 +224,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.
}
@@ -258,7 +240,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
@@ -284,13 +266,12 @@ 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
@NavigationModeSwitch
@PortraitLandscape
@TestStabilityRule.Stability(flavors = LOCAL | PLATFORM_POSTSUBMIT) // b/325659406
public void testQuickSwitchFromApp() throws Exception {
startTestActivity(2);
startTestActivity(3);
@@ -377,77 +358,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);
}
@Test
@PortraitLandscape
@TaskbarModeSwitch()
@Ignore("b/315376057")
public void testOverviewForTablet() throws Exception {
assumeTrue(mLauncher.isTablet());
for (int i = 2; i <= 14; i++) {
startTestActivity(i);
}
Overview overview = mLauncher.goHome().switchToOverview();
runOnRecentsView(recentsView -> assertTrue("Don't have at least 13 tasks",
recentsView.getTaskViewCount() >= 13));
// Test scroll the first task off screen
overview.scrollCurrentTaskOffScreen();
assertIsInState("Launcher internal state is not Overview", ExpectedState.OVERVIEW);
runOnRecentsView(recentsView -> assertTrue("Current task in Overview is still 0",
recentsView.getCurrentPage() > 0));
// Test opening the task.
overview.getCurrentTask().open();
assertTrue("Test activity didn't open from Overview",
mDevice.wait(Until.hasObject(By.pkg(getAppPackageName()).text(
mLauncher.isGridOnlyOverviewEnabled() ? "TestActivity12"
: "TestActivity13")),
TestUtil.DEFAULT_UI_TIMEOUT));
// Scroll the task offscreen as it is now first
overview = mLauncher.goHome().switchToOverview();
overview.scrollCurrentTaskOffScreen();
assertIsInState(
"Launcher internal state is not Overview", ExpectedState.OVERVIEW);
runOnRecentsView(recentsView -> assertTrue("Current task in Overview is still 0",
recentsView.getCurrentPage() > 0));
// Test dismissing the later task.
final Integer numTasks = getFromRecentsView(RecentsView::getTaskViewCount);
overview.getCurrentTask().dismiss();
runOnRecentsView(recentsView -> assertEquals(
"Dismissing a task didn't remove 1 task from Overview",
numTasks - 1, recentsView.getTaskViewCount()));
runOnRecentsView(recentsView -> assertTrue("Grid did not rebalance after dismissal",
(Math.abs(recentsView.getTopRowTaskCountForTablet()
- recentsView.getBottomRowTaskCountForTablet()) <= 1)));
// Test dismissing more tasks.
assertIsInState(
"Launcher internal state didn't remain in Overview", ExpectedState.OVERVIEW);
overview.getCurrentTask().dismiss();
assertIsInState(
"Launcher internal state didn't remain in Overview", ExpectedState.OVERVIEW);
overview.getCurrentTask().dismiss();
runOnRecentsView(recentsView -> assertTrue(
"Grid did not rebalance after multiple dismissals",
(Math.abs(recentsView.getTopRowTaskCountForTablet()
- recentsView.getBottomRowTaskCountForTablet()) <= 1)));
// Test dismissing all tasks.
mLauncher.goHome().switchToOverview().dismissAllTasks();
assertIsInState("Launcher internal state is not Home", ExpectedState.HOME);
runOnRecentsView(recentsView -> assertEquals("Still have tasks after dismissing all",
0, recentsView.getTaskViewCount()));
waitForState("Launcher internal state didn't switch to Home", LauncherState.NORMAL);
}
@Test
@@ -456,18 +371,18 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
startTestAppsWithCheck();
Overview overview = mLauncher.goHome().switchToOverview();
assertIsInState("Launcher internal state should be Overview", ExpectedState.OVERVIEW);
runOnRecentsView(recentsView -> assertTrue("Should have at least 3 tasks",
assertIsInState("Launcher internal state should be Overview", LauncherState.OVERVIEW);
executeOnOverview(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
@@ -479,28 +394,28 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
startTestAppsWithCheck();
Overview overview = mLauncher.goHome().switchToOverview();
assertIsInState("Launcher internal state should be Overview", ExpectedState.OVERVIEW);
runOnRecentsView(recentsView -> assertTrue("Should have at least 3 tasks",
assertIsInState("Launcher internal state should be Overview", LauncherState.OVERVIEW);
executeOnOverview(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);
}
}
@@ -541,75 +456,157 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
@Test
@PortraitLandscape
@ScreenRecordRule.ScreenRecord // TODO(b/396447643): Remove screen record.
public void testDismissCancel() throws Exception {
startTestAppsWithCheck();
Overview overview = mLauncher.goHome().switchToOverview();
assertIsInState("Launcher internal state didn't switch to Overview",
ExpectedState.OVERVIEW);
final Integer numTasks = getFromRecentsView(RecentsView::getTaskViewCount);
LauncherState.OVERVIEW);
final Integer numTasks = getFromOverview(RecentsView::getTaskViewCount);
OverviewTask task = overview.getCurrentTask();
assertNotNull("overview.getCurrentTask() returned null (2)", task);
task.dismissCancel();
runOnRecentsView(recentsView -> assertEquals(
executeOnOverview(recentsView -> assertEquals(
"Canceling dismissing a task removed a task from Overview",
numTasks == null ? 0 : numTasks, recentsView.getTaskViewCount()));
}
@Test
@PortraitLandscape
@EnableFlags(value = Flags.FLAG_ENABLE_GRID_ONLY_OVERVIEW)
public void testDismissBottomRow() throws Exception {
assumeTrue(mLauncher.isTablet());
mLauncher.goHome().switchToOverview().dismissAllTasks();
clearAllRecentTasks();
startTestAppsWithCheck();
Overview overview = mLauncher.goHome().switchToOverview();
assertIsInState("Launcher internal state didn't switch to Overview",
ExpectedState.OVERVIEW);
final Integer numTasks = getFromRecentsView(RecentsView::getTaskViewCount);
OverviewTask bottomTask = overview.getCurrentTasksForTablet().stream().max(
Comparator.comparingInt(OverviewTask::getTaskCenterY)).get();
assertNotNull("bottomTask null", bottomTask);
LauncherState.OVERVIEW);
final Integer numTasks = getFromOverview(RecentsView::getTaskViewCount);
Optional<OverviewTask> bottomTask = overview.getCurrentTasksForTablet().stream().max(
Comparator.comparingInt(OverviewTask::getTaskCenterY));
assertTrue("bottomTask null", bottomTask.isPresent());
bottomTask.dismiss();
runOnRecentsView(recentsView -> assertEquals(
bottomTask.get().dismiss();
executeOnOverview(recentsView -> assertEquals(
"Dismissing a bottomTask didn't remove 1 bottomTask from Overview",
numTasks - 1, recentsView.getTaskViewCount()));
}
@Test
@PortraitLandscape
@EnableFlags(value = Flags.FLAG_ENABLE_GRID_ONLY_OVERVIEW)
public void testDismissLastGridRow() throws Exception {
assumeTrue(mLauncher.isTablet());
mLauncher.goHome().switchToOverview().dismissAllTasks();
clearAllRecentTasks();
startTestAppsWithCheck();
startTestActivity(3);
startTestActivity(4);
runOnRecentsView(
recentsView -> assertNotEquals("Grid overview should have unequal row counts",
recentsView.getTopRowTaskCountForTablet(),
recentsView.getBottomRowTaskCountForTablet()));
Overview overview = mLauncher.goHome().switchToOverview();
assertIsInState("Launcher internal state didn't switch to Overview",
ExpectedState.OVERVIEW);
overview.flingForwardUntilClearAllVisible();
assertTrue("Clear All not visible.", overview.isClearAllVisible());
final Integer numTasks = getFromRecentsView(RecentsView::getTaskViewCount);
OverviewTask lastGridTask = overview.getCurrentTasksForTablet().stream().min(
Comparator.comparingInt(OverviewTask::getTaskCenterX)).get();
assertNotNull("lastGridTask null.", lastGridTask);
lastGridTask.dismiss();
runOnRecentsView(recentsView -> assertEquals(
"Dismissing a lastGridTask didn't remove 1 lastGridTask from Overview",
numTasks - 1, recentsView.getTaskViewCount()));
runOnRecentsView(recentsView -> assertEquals("Grid overview should have equal row counts.",
executeOnOverview(recentsView -> assertNotEquals(
"Grid overview should have unequal row counts",
recentsView.getTopRowTaskCountForTablet(),
recentsView.getBottomRowTaskCountForTablet()));
Overview overview = mLauncher.goHome().switchToOverview();
assertIsInState("Launcher internal state didn't switch to Overview",
LauncherState.OVERVIEW);
overview.flingForwardUntilClearAllVisible();
assertTrue("Clear All not visible.", overview.isClearAllVisible());
final Integer numTasks = getFromOverview(RecentsView::getTaskViewCount);
Optional<OverviewTask> lastGridTask = overview.getCurrentTasksForTablet().stream().min(
Comparator.comparingInt(OverviewTask::getTaskCenterX));
assertTrue("lastGridTask null.", lastGridTask.isPresent());
lastGridTask.get().dismiss();
executeOnOverview(recentsView -> {
assertEquals(
"Dismissing a lastGridTask didn't remove 1 lastGridTask from Overview",
numTasks - 1, recentsView.getTaskViewCount());
assertEquals(
"Grid overview should have equal row counts.",
recentsView.getTopRowTaskCountForTablet(),
recentsView.getBottomRowTaskCountForTablet());
});
assertTrue("Clear All not visible.", overview.isClearAllVisible());
}
@Test
@PortraitLandscape
@EnableFlags(value = Flags.FLAG_ENABLE_GRID_ONLY_OVERVIEW)
// When dismissing multiple apps, the apps off screen should "re-balance" i.e. re-arrange
// themselves evenly across both top and bottom rows.
public void gridRebalancesOffScreenAfterDismissingMultipleApps() throws Exception {
assumeTrue(mLauncher.isTablet());
clearAllRecentTasks();
// Launch enough apps so some are offscreen.
for (int i = 2; i <= 12; i++) {
startTestActivity(i);
}
Overview overview = mLauncher.goHome().switchToOverview();
executeOnOverview(recentsView -> assertTrue("11 tasks should be open",
recentsView.getTaskViewCount() >= 11));
// Dismiss 2 tasks from the top row.
assertIsInState(
"Launcher internal state didn't remain in Overview", LauncherState.OVERVIEW);
overview.getCurrentTask().dismiss();
assertIsInState(
"Launcher internal state didn't remain in Overview", LauncherState.OVERVIEW);
overview.getCurrentTask().dismiss();
// Assert that the two row counts are no more than 1 apart, therefore were re-balanced.
executeOnOverview(recentsView -> assertTrue(
"Grid did not re-balance after multiple dismissals",
(Math.abs(recentsView.getTopRowTaskCountForTablet()
- recentsView.getBottomRowTaskCountForTablet()) <= 1)));
}
@Test
@PortraitLandscape
@EnableFlags(value = Flags.FLAG_ENABLE_GRID_ONLY_OVERVIEW)
// When dismissing multiple apps, the apps on screen should not "re-balance" i.e. dismissing
// 2 apps from the top row, will move the top row along 2 and so it will not be balanced
// across the bottom row.
public void gridDoesNotRebalanceOnScreenAfterDismissingMultipleApps() throws Exception {
assumeTrue(mLauncher.isTablet());
clearAllRecentTasks();
// Launch 6 apps so 3 are in each row.
int appsInBothRowsCount = 6;
int appsInEachRowCount = appsInBothRowsCount / 2;
for (int i = 2; i <= appsInBothRowsCount + 1; i++) {
startTestActivity(i);
}
Overview overview = mLauncher.goHome().switchToOverview();
executeOnOverview(recentsView -> {
assertEquals(appsInBothRowsCount + " tasks should be open",
appsInBothRowsCount, recentsView.getTaskViewCount());
assertEquals("Grid should have " + appsInEachRowCount + " tasks on the top row",
appsInEachRowCount,
recentsView.getTopRowTaskCountForTablet());
assertEquals("Grid should have " + appsInEachRowCount + " tasks on the bottom row",
appsInEachRowCount,
recentsView.getBottomRowTaskCountForTablet());
});
// Dismiss 2 tasks from the top row.
assertIsInState("Launcher internal state didn't remain in Overview",
LauncherState.OVERVIEW);
overview.getCurrentTask().dismiss();
assertIsInState("Launcher internal state didn't remain in Overview",
LauncherState.OVERVIEW);
overview.getCurrentTask().dismiss();
executeOnOverview(recentsView -> {
int expectedTopRowCount = appsInEachRowCount - 2;
assertEquals(
"Grid should have " + expectedTopRowCount + " tasks on the top row",
expectedTopRowCount,
recentsView.getTopRowTaskCountForTablet());
assertEquals("Grid should have " + appsInEachRowCount + " tasks on the bottom row",
appsInEachRowCount,
recentsView.getBottomRowTaskCountForTablet());
});
}
private void startTestAppsWithCheck() throws Exception {
@@ -636,19 +633,13 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
}
private void assertIsInState(
@NonNull String failureMessage, @NonNull ExpectedState expectedState) {
assertTrue(failureMessage, enableLauncherOverviewInWindow()
? isInRecentsWindowState(() -> expectedState.mRecentsState)
: isInState(() -> expectedState.mLauncherState));
@NonNull String failureMessage, @NonNull LauncherState expectedState) {
assertTrue(failureMessage, isInState(() -> expectedState));
}
private void waitForState(
@NonNull String failureMessage, @NonNull ExpectedState expectedState) {
if (enableLauncherOverviewInWindow()) {
waitForRecentsWindowState(failureMessage, () -> expectedState.mRecentsState);
} else {
waitForState(failureMessage, () -> expectedState.mLauncherState);
}
@NonNull String failureMessage, @NonNull LauncherState expectedState) {
waitForState(failureMessage, () -> expectedState);
}
private void expectLaunchedAppState() {
@@ -657,33 +648,4 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
+ "one",
isInLaunchedApp(launcher)));
}
private <T> T getFromRecentsView(Function<RecentsView, T> f) {
return getFromRecentsView(f, false);
}
private <T> T getFromRecentsView(Function<RecentsView, T> f, boolean forTearDown) {
if (enableLauncherOverviewInWindow()) {
return getFromRecentsWindow(recentsWindowManager ->
(forTearDown && recentsWindowManager == null)
? null : f.apply(recentsWindowManager.getOverviewPanel()));
} else {
return getFromLauncher(launcher -> (forTearDown && launcher == null)
? null : f.apply(launcher.getOverviewPanel()));
}
}
private void runOnRecentsView(Consumer<RecentsView> f) {
runOnRecentsView(f, false);
}
private void runOnRecentsView(Consumer<RecentsView> f, boolean forTearDown) {
getFromRecentsView(recentsView -> {
if (forTearDown && recentsView == null) {
return null;
}
f.accept(recentsView);
return null;
}, forTearDown);
}
}
@@ -23,7 +23,7 @@ import static com.android.quickstep.TaplTestsTaskbar.TaskbarMode.TRANSIENT;
import androidx.test.filters.LargeTest;
import com.android.launcher3.ui.PortraitLandscapeRunner.PortraitLandscape;
import com.android.launcher3.util.ui.PortraitLandscapeRunner.PortraitLandscape;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -29,7 +29,7 @@ import androidx.test.runner.AndroidJUnit4;
import com.android.launcher3.tapl.LauncherInstrumentation.TrackpadGestureType;
import com.android.launcher3.tapl.Workspace;
import com.android.launcher3.ui.PortraitLandscapeRunner.PortraitLandscape;
import com.android.launcher3.util.ui.PortraitLandscapeRunner.PortraitLandscape;
import com.android.quickstep.NavigationModeSwitchRule.NavigationModeSwitch;
import org.junit.After;
@@ -18,6 +18,7 @@ package com.android.quickstep;
import static com.android.launcher3.Flags.enableCursorHoverStates;
import static com.android.launcher3.util.TestConstants.AppNames.TEST_APP_NAME;
import static com.android.quickstep.TaskbarModeSwitchRule.Mode.TRANSIENT;
import static com.android.systemui.shared.Flags.cursorHotCorner;
import static org.junit.Assume.assumeTrue;
@@ -41,14 +42,6 @@ public class TaplTestsTransientTaskbar extends AbstractTaplTestsTaskbar {
mLauncher.getLaunchedAppState().hoverToShowTaskbarUnstashHint();
}
@Test
@TaskbarModeSwitch(mode = TRANSIENT)
public void testUnstashTaskbarOnScreenBottomEdgeHover() {
assumeTrue(enableCursorHoverStates());
getTaskbar().getAppIcon(TEST_APP_NAME).launch(TEST_APP_PACKAGE);
mLauncher.getLaunchedAppState().hoverScreenBottomEdgeToUnstashTaskbar();
}
@Test
@TaskbarModeSwitch(mode = TRANSIENT)
public void testHoverBelowHintedTaskbarToUnstash() {
@@ -71,4 +64,31 @@ public class TaplTestsTransientTaskbar extends AbstractTaplTestsTaskbar {
getTaskbar().swipeDownToStash();
mLauncher.getLaunchedAppState().swipeUpToUnstashTaskbar();
}
@Test
@TaskbarModeSwitch(mode = TRANSIENT)
public void testUnstashTaskbarOnScreenBottomEdgeHover() {
assumeTrue(enableCursorHoverStates());
getTaskbar().getAppIcon(TEST_APP_NAME).launch(TEST_APP_PACKAGE);
mLauncher.getLaunchedAppState().hoverScreenBottomEdgeToUnstashTaskbar();
mLauncher.getLaunchedAppState().assertTaskbarVisible();
}
@Test
@TaskbarModeSwitch(mode = TRANSIENT)
public void testUnstashTaskbarOnScreenBottomEdgeOutsideActionCornerHover() {
assumeTrue(cursorHotCorner());
getTaskbar().getAppIcon(TEST_APP_NAME).launch(TEST_APP_PACKAGE);
mLauncher.getLaunchedAppState().hoverScreenBottomEdgeOutsideActionCornerToUnstashTaskbar();
mLauncher.getLaunchedAppState().assertTaskbarVisible();
}
@Test
@TaskbarModeSwitch(mode = TRANSIENT)
public void testNotShowTaskbarOnActionCornerPaddingHover() {
assumeTrue(cursorHotCorner());
getTaskbar().getAppIcon(TEST_APP_NAME).launch(TEST_APP_PACKAGE);
mLauncher.getLaunchedAppState().hoverScreenBottomCornerToTryUnstashTaskbar();
mLauncher.getLaunchedAppState().assertTaskbarHidden();
}
}
@@ -16,6 +16,9 @@
package com.android.quickstep;
import static com.android.quickstep.TaskViewTestDIHelpers.initializeRecentsDependencies;
import static com.android.quickstep.TaskViewTestDIHelpers.mockRecentsModel;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyInt;
@@ -35,11 +38,15 @@ import android.util.DisplayMetrics;
import android.view.MotionEvent;
import androidx.test.filters.SmallTest;
import androidx.test.platform.app.InstrumentationRegistry;
import com.android.launcher3.uioverrides.QuickstepLauncher;
import com.android.launcher3.util.SandboxContext;
import com.android.quickstep.recents.di.RecentsDependencies;
import com.android.quickstep.util.BorderAnimator;
import com.android.quickstep.views.TaskView;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
@@ -48,6 +55,8 @@ import org.mockito.MockitoAnnotations;
@SmallTest
public class TaskViewTest {
private final SandboxContext mApplicationContext =
new SandboxContext(InstrumentationRegistry.getInstrumentation().getTargetContext());
@Mock
private QuickstepLauncher mContext;
@Mock
@@ -69,10 +78,19 @@ public class TaskViewTest {
when(mContext.getApplicationInfo()).thenReturn(mock(ApplicationInfo.class));
when(mContext.obtainStyledAttributes(any(), any(), anyInt(), anyInt())).thenReturn(
mock(TypedArray.class));
when(mContext.getApplicationContext()).thenReturn(mApplicationContext);
mApplicationContext.initDaggerComponent(
DaggerTaskViewTestComponent.builder().bindRecentsModel(mockRecentsModel()));
initializeRecentsDependencies(mContext);
mTaskView = new TaskView(mContext, null, 0, 0, mFocusAnimator, mHoverAnimator);
}
@After
public void tearDown() {
RecentsDependencies.destroy(mContext);
}
@Test
public void notShowBorderOnBorderDisabled() {
presetBorderStatus(/* enabled= */ true);
@@ -27,9 +27,9 @@ import android.util.Log;
import com.android.launcher3.tapl.LauncherInstrumentation;
import com.android.launcher3.tapl.TestHelpers;
import com.android.launcher3.ui.AbstractLauncherUiTest;
import com.android.launcher3.util.DisplayController;
import com.android.launcher3.util.rule.FailureWatcher;
import com.android.launcher3.util.ui.AbstractLauncherUiTest;
import org.junit.rules.TestRule;
import org.junit.runner.Description;
@@ -40,7 +40,7 @@ import com.android.internal.jank.Cuj
import com.android.launcher3.desktop.DesktopAppLaunchAnimatorHelper
import com.android.launcher3.desktop.DesktopAppLaunchTransition.AppLaunchType
import com.android.launcher3.util.Executors.MAIN_EXECUTOR
import com.android.window.flags.Flags
import com.android.window.flags2.Flags
import com.google.common.truth.Truth.assertThat
import org.junit.Before
import org.junit.Rule
@@ -20,7 +20,7 @@ import androidx.test.uiautomator.By
import com.android.launcher3.tapl.LauncherInstrumentation
import com.android.launcher3.tapl.Overview
import com.android.launcher3.tapl.OverviewTask
import com.android.launcher3.ui.AbstractLauncherUiTest
import com.android.launcher3.util.ui.AbstractLauncherUiTest
object SplitScreenTestUtils {
@@ -22,12 +22,13 @@ import android.app.ActivityTaskManager.INVALID_TASK_ID
import android.content.Context
import android.content.ContextWrapper
import android.content.Intent
import android.os.Process
import android.os.UserHandle
import androidx.test.platform.app.InstrumentationRegistry
import com.android.launcher3.model.data.ItemInfo
import com.android.launcher3.shortcuts.ShortcutKey
import com.android.launcher3.ui.AbstractLauncherUiTest
import com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT
import com.android.launcher3.util.ui.AbstractLauncherUiTest
import com.android.quickstep.util.SplitSelectDataHolder.Companion.SPLIT_PENDINGINTENT_PENDINGINTENT
import com.android.quickstep.util.SplitSelectDataHolder.Companion.SPLIT_PENDINGINTENT_TASK
import com.android.quickstep.util.SplitSelectDataHolder.Companion.SPLIT_SHORTCUT_TASK
@@ -54,7 +55,7 @@ class SplitSelectDataHolderTest {
private val sampleTaskInfo = RunningTaskInfo()
private val sampleTaskId = 10
private val sampleTaskId2 = 11
private val sampleUser = UserHandle(0)
private val sampleUser = UserHandle(Process.myUserHandle().identifier)
private val sampleIntent = Intent()
private val sampleIntent2 = Intent()
private val sampleShortcut = Intent()
@@ -84,7 +85,7 @@ class SplitSelectDataHolderTest {
sampleTaskInfo,
STAGE_POSITION_TOP_OR_LEFT,
null,
null
null,
)
assertTrue(splitSelectDataHolder.isSplitSelectActive())
}
@@ -96,7 +97,7 @@ class SplitSelectDataHolderTest {
STAGE_POSITION_TOP_OR_LEFT,
sampleItemInfo,
null,
INVALID_TASK_ID
INVALID_TASK_ID,
)
assertTrue(splitSelectDataHolder.isSplitSelectActive())
}
@@ -108,7 +109,7 @@ class SplitSelectDataHolderTest {
STAGE_POSITION_TOP_OR_LEFT,
sampleItemInfo,
null,
sampleTaskId
sampleTaskId,
)
assertTrue(splitSelectDataHolder.isSplitSelectActive())
}
@@ -120,7 +121,7 @@ class SplitSelectDataHolderTest {
STAGE_POSITION_TOP_OR_LEFT,
sampleItemInfo,
null,
INVALID_TASK_ID
INVALID_TASK_ID,
)
assertTrue(splitSelectDataHolder.isSplitSelectActive())
}
@@ -132,7 +133,7 @@ class SplitSelectDataHolderTest {
STAGE_POSITION_TOP_OR_LEFT,
sampleItemInfo,
null,
INVALID_TASK_ID
INVALID_TASK_ID,
)
splitSelectDataHolder.setSecondTask(sampleTaskId, sampleItemInfo2)
assertTrue(splitSelectDataHolder.isBothSplitAppsConfirmed())
@@ -144,7 +145,7 @@ class SplitSelectDataHolderTest {
sampleTaskInfo,
STAGE_POSITION_TOP_OR_LEFT,
null,
null
null,
)
splitSelectDataHolder.setSecondTask(sampleIntent, sampleUser, sampleItemInfo2)
assertTrue(splitSelectDataHolder.isBothSplitAppsConfirmed())
@@ -157,7 +158,7 @@ class SplitSelectDataHolderTest {
STAGE_POSITION_TOP_OR_LEFT,
sampleItemInfo,
null,
INVALID_TASK_ID
INVALID_TASK_ID,
)
splitSelectDataHolder.setSecondTask(sampleShortcut, sampleUser, sampleItemInfo2)
assertTrue(splitSelectDataHolder.isBothSplitAppsConfirmed())
@@ -169,7 +170,7 @@ class SplitSelectDataHolderTest {
sampleTaskInfo,
STAGE_POSITION_TOP_OR_LEFT,
sampleItemInfo,
null
null,
)
splitSelectDataHolder.setSecondTask(sampleTaskId2, sampleItemInfo2)
val launchData = splitSelectDataHolder.getSplitLaunchData()
@@ -193,7 +194,7 @@ class SplitSelectDataHolderTest {
sampleTaskInfo,
STAGE_POSITION_TOP_OR_LEFT,
sampleItemInfo,
null
null,
)
splitSelectDataHolder.setSecondTask(sampleIntent, sampleUser, sampleItemInfo2)
val launchData = splitSelectDataHolder.getSplitLaunchData()
@@ -217,7 +218,7 @@ class SplitSelectDataHolderTest {
sampleTaskInfo,
STAGE_POSITION_TOP_OR_LEFT,
sampleItemInfo,
null
null,
)
splitSelectDataHolder.setSecondTask(sampleShortcut, sampleUser, sampleItemInfo2)
val launchData = splitSelectDataHolder.getSplitLaunchData()
@@ -242,7 +243,7 @@ class SplitSelectDataHolderTest {
STAGE_POSITION_TOP_OR_LEFT,
sampleItemInfo,
null,
INVALID_TASK_ID
INVALID_TASK_ID,
)
splitSelectDataHolder.setSecondTask(sampleTaskId, sampleItemInfo2)
val launchData = splitSelectDataHolder.getSplitLaunchData()
@@ -267,7 +268,7 @@ class SplitSelectDataHolderTest {
STAGE_POSITION_TOP_OR_LEFT,
sampleItemInfo,
null,
INVALID_TASK_ID
INVALID_TASK_ID,
)
splitSelectDataHolder.setSecondTask(sampleTaskId, sampleItemInfo2)
val launchData = splitSelectDataHolder.getSplitLaunchData()
@@ -292,7 +293,7 @@ class SplitSelectDataHolderTest {
STAGE_POSITION_TOP_OR_LEFT,
sampleItemInfo,
null,
INVALID_TASK_ID
INVALID_TASK_ID,
)
splitSelectDataHolder.setSecondTask(sampleIntent2, sampleUser, sampleItemInfo2)
val launchData = splitSelectDataHolder.getSplitLaunchData()
@@ -316,7 +317,7 @@ class SplitSelectDataHolderTest {
sampleTaskInfo,
STAGE_POSITION_TOP_OR_LEFT,
sampleItemInfo,
null
null,
)
val launchData = splitSelectDataHolder.getFullscreenLaunchData()
@@ -340,7 +341,7 @@ class SplitSelectDataHolderTest {
STAGE_POSITION_TOP_OR_LEFT,
sampleItemInfo,
null,
INVALID_TASK_ID
INVALID_TASK_ID,
)
val launchData = splitSelectDataHolder.getFullscreenLaunchData()
@@ -364,7 +365,7 @@ class SplitSelectDataHolderTest {
STAGE_POSITION_TOP_OR_LEFT,
sampleItemInfo,
null,
INVALID_TASK_ID
INVALID_TASK_ID,
)
val launchData = splitSelectDataHolder.getFullscreenLaunchData()
@@ -387,7 +388,7 @@ class SplitSelectDataHolderTest {
sampleTaskInfo,
STAGE_POSITION_TOP_OR_LEFT,
null,
null
null,
)
splitSelectDataHolder.setSecondTask(sampleIntent, sampleUser, sampleItemInfo2)
splitSelectDataHolder.resetState()
@@ -397,11 +398,11 @@ class SplitSelectDataHolderTest {
@Test
fun clearState_intent() {
splitSelectDataHolder.setInitialTaskSelect(
sampleIntent,
STAGE_POSITION_TOP_OR_LEFT,
sampleItemInfo,
null,
INVALID_TASK_ID
sampleIntent,
STAGE_POSITION_TOP_OR_LEFT,
sampleItemInfo,
null,
INVALID_TASK_ID,
)
splitSelectDataHolder.setSecondTask(sampleIntent, sampleUser, sampleItemInfo2)
splitSelectDataHolder.resetState()