fix: Conflict incoming changes from 15-dev
This commit is contained in:
1 parent
14e352c827
commit
2e76c99dad
1726 files changed
+146970
-95027
No files matched your search
+30
-2
@@ -25,10 +25,13 @@ import android.platform.test.flag.junit.SetFlagsRule
|
||||
import android.view.WindowManager.TRANSIT_OPEN
|
||||
import android.view.WindowManager.TRANSIT_TO_FRONT
|
||||
import android.window.TransitionFilter
|
||||
import android.window.TransitionFilter.CONTAINER_ORDER_ANY
|
||||
import android.window.TransitionFilter.CONTAINER_ORDER_TOP
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.filters.SmallTest
|
||||
import com.android.quickstep.SystemUiProxy
|
||||
import com.android.window.flags.Flags.FLAG_ENABLE_DESKTOP_APP_LAUNCH_TRANSITIONS_BUGFIX
|
||||
import com.android.window.flags2.Flags.FLAG_ENABLE_DESKTOP_APP_LAUNCH_BUGFIX
|
||||
import com.android.window.flags2.Flags.FLAG_ENABLE_DESKTOP_APP_LAUNCH_TRANSITIONS_BUGFIX
|
||||
import com.android.wm.shell.shared.desktopmode.DesktopModeStatus
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import org.junit.Before
|
||||
@@ -77,7 +80,8 @@ class DesktopAppLaunchTransitionManagerTest {
|
||||
|
||||
@Test
|
||||
@EnableFlags(FLAG_ENABLE_DESKTOP_APP_LAUNCH_TRANSITIONS_BUGFIX)
|
||||
fun registerTransitions_usesCorrectFilter() {
|
||||
@DisableFlags(FLAG_ENABLE_DESKTOP_APP_LAUNCH_BUGFIX)
|
||||
fun registerTransitions_usesCorrectFilter_flagDisabled() {
|
||||
transitionManager.registerTransitions()
|
||||
val filterArgumentCaptor = argumentCaptor<TransitionFilter>()
|
||||
|
||||
@@ -92,5 +96,29 @@ class DesktopAppLaunchTransitionManagerTest {
|
||||
assertThat(launchRequirement.mModes).isEqualTo(intArrayOf(TRANSIT_OPEN, TRANSIT_TO_FRONT))
|
||||
assertThat(launchRequirement.mActivityType).isEqualTo(ACTIVITY_TYPE_STANDARD)
|
||||
assertThat(launchRequirement.mWindowingMode).isEqualTo(WINDOWING_MODE_FREEFORM)
|
||||
assertThat(launchRequirement.mOrder).isEqualTo(CONTAINER_ORDER_TOP)
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(
|
||||
FLAG_ENABLE_DESKTOP_APP_LAUNCH_TRANSITIONS_BUGFIX,
|
||||
FLAG_ENABLE_DESKTOP_APP_LAUNCH_BUGFIX,
|
||||
)
|
||||
fun registerTransitions_usesCorrectFilter_flagEnabled() {
|
||||
transitionManager.registerTransitions()
|
||||
val filterArgumentCaptor = argumentCaptor<TransitionFilter>()
|
||||
|
||||
verify(systemUiProxy, times(1))
|
||||
.registerRemoteTransition(any(), filterArgumentCaptor.capture())
|
||||
|
||||
assertThat(filterArgumentCaptor.lastValue).isNotNull()
|
||||
assertThat(filterArgumentCaptor.lastValue.mTypeSet)
|
||||
.isEqualTo(intArrayOf(TRANSIT_OPEN, TRANSIT_TO_FRONT))
|
||||
assertThat(filterArgumentCaptor.lastValue.mRequirements).hasLength(1)
|
||||
val launchRequirement = filterArgumentCaptor.lastValue.mRequirements!![0]
|
||||
assertThat(launchRequirement.mModes).isEqualTo(intArrayOf(TRANSIT_OPEN, TRANSIT_TO_FRONT))
|
||||
assertThat(launchRequirement.mActivityType).isEqualTo(ACTIVITY_TYPE_STANDARD)
|
||||
assertThat(launchRequirement.mWindowingMode).isEqualTo(WINDOWING_MODE_FREEFORM)
|
||||
assertThat(launchRequirement.mOrder).isEqualTo(CONTAINER_ORDER_ANY)
|
||||
}
|
||||
}
|
||||
+30
-25
@@ -19,15 +19,16 @@ import android.app.prediction.AppPredictor
|
||||
import android.app.prediction.AppTarget
|
||||
import android.app.prediction.AppTargetEvent
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import com.android.launcher3.LauncherAppState
|
||||
import com.android.launcher3.LauncherSettings.Favorites.CONTAINER_ALL_APPS_PREDICTION
|
||||
import com.android.launcher3.LauncherSettings.Favorites.CONTAINER_HOTSEAT_PREDICTION
|
||||
import com.android.launcher3.LauncherSettings.Favorites.CONTAINER_PREDICTION
|
||||
import com.android.launcher3.LauncherSettings.Favorites.CONTAINER_WALLPAPERS
|
||||
import com.android.launcher3.LauncherSettings.Favorites.CONTAINER_WIDGETS_PREDICTION
|
||||
import com.android.launcher3.util.LauncherModelHelper
|
||||
import org.junit.After
|
||||
import com.android.launcher3.util.SandboxApplication
|
||||
import org.junit.Assert.assertNotSame
|
||||
import org.junit.Assert.assertSame
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Mock
|
||||
@@ -35,46 +36,50 @@ import org.mockito.Mockito.never
|
||||
import org.mockito.Mockito.verify
|
||||
import org.mockito.Mockito.verifyNoMoreInteractions
|
||||
import org.mockito.MockitoAnnotations
|
||||
import org.mockito.kotlin.mock
|
||||
|
||||
/** Unit tests for [QuickstepModelDelegate]. */
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class QuickstepModelDelegateTest {
|
||||
|
||||
@get:Rule val context = SandboxApplication().withModelDependency()
|
||||
|
||||
private lateinit var underTest: QuickstepModelDelegate
|
||||
private lateinit var modelHelper: LauncherModelHelper
|
||||
|
||||
@Mock private lateinit var target: AppTarget
|
||||
@Mock private lateinit var mockedAppTargetEvent: AppTargetEvent
|
||||
@Mock private lateinit var allAppsPredictor: AppPredictor
|
||||
@Mock private lateinit var hotseatPredictor: AppPredictor
|
||||
@Mock private lateinit var widgetRecommendationPredictor: AppPredictor
|
||||
@Mock private lateinit var itemParserFactory: PredictedItemFactory.Factory
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
modelHelper = LauncherModelHelper()
|
||||
underTest =
|
||||
QuickstepModelDelegate(
|
||||
modelHelper.sandboxContext,
|
||||
modelHelper.sandboxContext.appComponent.idp,
|
||||
modelHelper.sandboxContext.appComponent.packageManagerHelper,
|
||||
context,
|
||||
context.appComponent.idp,
|
||||
context.appComponent.userCache,
|
||||
itemParserFactory,
|
||||
"", /* dbFileName */
|
||||
)
|
||||
underTest.mAllAppsState.predictor = allAppsPredictor
|
||||
underTest.mHotseatState.predictor = hotseatPredictor
|
||||
underTest.mAllPredictionAppsState.predictor = allAppsPredictor
|
||||
underTest.mHotseatPredictionState.predictor = hotseatPredictor
|
||||
underTest.mWidgetsRecommendationState.predictor = widgetRecommendationPredictor
|
||||
underTest.mModel = modelHelper.model
|
||||
underTest.mDataModel = BgDataModel(WidgetsModel(modelHelper.sandboxContext))
|
||||
}
|
||||
|
||||
@After
|
||||
fun tearDown() {
|
||||
modelHelper.destroy()
|
||||
underTest.mModel = LauncherAppState.getInstance(context).model
|
||||
underTest.mDataModel =
|
||||
BgDataModel(
|
||||
WidgetsModel(context),
|
||||
/* homeDataProvider */ { null },
|
||||
/* dumpManager */ mock(),
|
||||
/* DaggerSingletonTracker */ mock(),
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun onAppTargetEvent_notifyTarget() {
|
||||
underTest.onAppTargetEvent(mockedAppTargetEvent, CONTAINER_PREDICTION)
|
||||
underTest.onAppTargetEvent(mockedAppTargetEvent, CONTAINER_ALL_APPS_PREDICTION)
|
||||
|
||||
verify(allAppsPredictor).notifyAppTargetEvent(mockedAppTargetEvent)
|
||||
verifyNoMoreInteractions(hotseatPredictor)
|
||||
@@ -110,38 +115,38 @@ class QuickstepModelDelegateTest {
|
||||
|
||||
@Test
|
||||
fun hotseatActionPin_recreateHotSeat() {
|
||||
assertSame(underTest.mHotseatState.predictor, hotseatPredictor)
|
||||
assertSame(underTest.mHotseatPredictionState.predictor, hotseatPredictor)
|
||||
val appTargetEvent = AppTargetEvent.Builder(target, AppTargetEvent.ACTION_PIN).build()
|
||||
underTest.markActive()
|
||||
|
||||
underTest.onAppTargetEvent(appTargetEvent, CONTAINER_HOTSEAT_PREDICTION)
|
||||
|
||||
verify(hotseatPredictor).destroy()
|
||||
assertNotSame(underTest.mHotseatState.predictor, hotseatPredictor)
|
||||
assertNotSame(underTest.mHotseatPredictionState.predictor, hotseatPredictor)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun hotseatActionUnpin_recreateHotSeat() {
|
||||
assertSame(underTest.mHotseatState.predictor, hotseatPredictor)
|
||||
assertSame(underTest.mHotseatPredictionState.predictor, hotseatPredictor)
|
||||
underTest.markActive()
|
||||
val appTargetEvent = AppTargetEvent.Builder(target, AppTargetEvent.ACTION_UNPIN).build()
|
||||
|
||||
underTest.onAppTargetEvent(appTargetEvent, CONTAINER_HOTSEAT_PREDICTION)
|
||||
|
||||
verify(hotseatPredictor).destroy()
|
||||
assertNotSame(underTest.mHotseatState.predictor, hotseatPredictor)
|
||||
assertNotSame(underTest.mHotseatPredictionState.predictor, hotseatPredictor)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun container_actionPin_notRecreateHotSeat() {
|
||||
assertSame(underTest.mHotseatState.predictor, hotseatPredictor)
|
||||
assertSame(underTest.mHotseatPredictionState.predictor, hotseatPredictor)
|
||||
val appTargetEvent = AppTargetEvent.Builder(target, AppTargetEvent.ACTION_UNPIN).build()
|
||||
underTest.markActive()
|
||||
|
||||
underTest.onAppTargetEvent(appTargetEvent, CONTAINER_PREDICTION)
|
||||
underTest.onAppTargetEvent(appTargetEvent, CONTAINER_ALL_APPS_PREDICTION)
|
||||
|
||||
verify(allAppsPredictor, never()).destroy()
|
||||
verify(hotseatPredictor, never()).destroy()
|
||||
assertSame(underTest.mHotseatState.predictor, hotseatPredictor)
|
||||
assertSame(underTest.mHotseatPredictionState.predictor, hotseatPredictor)
|
||||
}
|
||||
}
|
||||
+6
-1
@@ -30,11 +30,13 @@ import com.android.launcher3.pm.UserCache
|
||||
import com.android.launcher3.util.AllModulesForTest
|
||||
import com.android.launcher3.util.SandboxContext
|
||||
import com.android.launcher3.util.SplitConfigurationOptions
|
||||
import com.android.launcher3.util.TestDispatcherProvider
|
||||
import com.android.launcher3.util.TransformingTouchDelegate
|
||||
import com.android.launcher3.util.UserIconInfo
|
||||
import com.android.quickstep.TaskOverlayFactory
|
||||
import com.android.quickstep.TaskOverlayFactory.TaskOverlay
|
||||
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.views.RecentsView
|
||||
import com.android.quickstep.views.TaskContainer
|
||||
@@ -47,6 +49,7 @@ import com.android.systemui.shared.recents.model.Task.TaskKey
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import dagger.BindsInstance
|
||||
import dagger.Component
|
||||
import kotlinx.coroutines.test.StandardTestDispatcher
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
@@ -64,6 +67,7 @@ class TaskViewItemInfoTest {
|
||||
private val overlayFactory = mock<TaskOverlayFactory>()
|
||||
private val userCache = mock<UserCache>()
|
||||
private val userInfo = mock<UserIconInfo>()
|
||||
private val dispatcher = StandardTestDispatcher()
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
@@ -76,7 +80,7 @@ class TaskViewItemInfoTest {
|
||||
context.initDaggerComponent(
|
||||
DaggerTaskViewItemInfoTest_TestComponent.builder().bindUserCache(userCache)
|
||||
)
|
||||
RecentsDependencies.maybeInitialize(context)
|
||||
RecentsDependencies.maybeInitialize(context, TestDispatcherProvider(dispatcher))
|
||||
}
|
||||
|
||||
@After
|
||||
@@ -198,6 +202,7 @@ class TaskViewItemInfoTest {
|
||||
return TaskContainer(
|
||||
taskView,
|
||||
task,
|
||||
mock<TaskContentView>(),
|
||||
if (enableRefactorTaskThumbnail()) mock<TaskThumbnailView>()
|
||||
else mock<TaskThumbnailViewDeprecated>(),
|
||||
mock<TaskViewIcon>(),
|
||||
|
||||
+2
@@ -60,6 +60,7 @@ abstract class TaskbarBaseTestCase {
|
||||
@Mock lateinit var optionalBubbleControllers: Optional<BubbleControllers>
|
||||
@Mock lateinit var taskbarDesktopModeController: TaskbarDesktopModeController
|
||||
@Mock lateinit var nudgeController: NudgeController
|
||||
@Mock lateinit var nudgeViewController: NudgeViewController
|
||||
|
||||
lateinit var taskbarControllers: TaskbarControllers
|
||||
|
||||
@@ -103,6 +104,7 @@ abstract class TaskbarBaseTestCase {
|
||||
optionalBubbleControllers,
|
||||
taskbarDesktopModeController,
|
||||
nudgeController,
|
||||
nudgeViewController
|
||||
)
|
||||
}
|
||||
}
|
||||
+9
@@ -147,6 +147,15 @@ class TaskbarHoverToolTipControllerTest {
|
||||
assertThat(isHoverToolTipOpen).isFalse()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun onHover_emptyTitle_noTooltip() {
|
||||
runOnMainSync {
|
||||
iconView.text = ""
|
||||
iconView.dispatchGenericMotionEvent(HOVER_ENTER)
|
||||
}
|
||||
assertThat(isHoverToolTipOpen).isFalse()
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val HOVER_EXIT = MotionEvent.obtain(0, 0, ACTION_HOVER_EXIT, 0f, 0f, 0)
|
||||
private val HOVER_ENTER = MotionEvent.obtain(0, 0, ACTION_HOVER_ENTER, 0f, 0f, 0)
|
||||
|
||||
+16
-3
@@ -15,7 +15,7 @@ import static com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_IM
|
||||
import static com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_RECENTS;
|
||||
import static com.android.launcher3.taskbar.TaskbarNavButtonController.SCREEN_PIN_LONG_PRESS_THRESHOLD;
|
||||
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_SCREEN_PINNING;
|
||||
import static com.android.window.flags.Flags.FLAG_PREDICTIVE_BACK_THREE_BUTTON_NAV;
|
||||
import static com.android.window.flags2.Flags.FLAG_PREDICTIVE_BACK_THREE_BUTTON_NAV;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
@@ -29,6 +29,7 @@ import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.graphics.Rect;
|
||||
import android.os.Handler;
|
||||
import android.platform.test.annotations.RequiresFlagsEnabled;
|
||||
import android.platform.test.flag.junit.CheckFlagsRule;
|
||||
@@ -87,12 +88,12 @@ public class TaskbarNavButtonControllerTest {
|
||||
private int mOverviewToggleCount;
|
||||
private final TaskbarNavButtonCallbacks mCallbacks = new TaskbarNavButtonCallbacks() {
|
||||
@Override
|
||||
public void onNavigateHome() {
|
||||
public void onNavigateHome(int displayId) {
|
||||
mHomePressCount++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onToggleOverview() {
|
||||
public void onToggleOverview(int displayId) {
|
||||
mOverviewToggleCount++;
|
||||
}
|
||||
};
|
||||
@@ -110,6 +111,7 @@ public class TaskbarNavButtonControllerTest {
|
||||
when(mockTaskbarControllers.getTaskbarActivityContext())
|
||||
.thenReturn(mockTaskbarActivityContext);
|
||||
doReturn(mockStatsLogManager).when(mockTaskbarActivityContext).getStatsLogManager();
|
||||
when(mockTaskbarActivityContext.getDisplayId()).thenReturn(DISPLAY_ID);
|
||||
mNavButtonController = new TaskbarNavButtonController(
|
||||
mockService,
|
||||
mCallbacks,
|
||||
@@ -343,6 +345,7 @@ public class TaskbarNavButtonControllerTest {
|
||||
@Test
|
||||
@RequiresFlagsEnabled(FLAG_PREDICTIVE_BACK_THREE_BUTTON_NAV)
|
||||
public void testPredictiveBackInvoked() {
|
||||
mNavButtonController.init(mockTaskbarControllers);
|
||||
ArgumentCaptor<KeyEvent> keyEventCaptor = ArgumentCaptor.forClass(KeyEvent.class);
|
||||
mNavButtonController.sendBackKeyEvent(KeyEvent.ACTION_DOWN, false);
|
||||
mNavButtonController.sendBackKeyEvent(KeyEvent.ACTION_UP, false);
|
||||
@@ -354,6 +357,7 @@ public class TaskbarNavButtonControllerTest {
|
||||
@Test
|
||||
@RequiresFlagsEnabled(FLAG_PREDICTIVE_BACK_THREE_BUTTON_NAV)
|
||||
public void testPredictiveBackCancelled() {
|
||||
mNavButtonController.init(mockTaskbarControllers);
|
||||
ArgumentCaptor<KeyEvent> keyEventCaptor = ArgumentCaptor.forClass(KeyEvent.class);
|
||||
mNavButtonController.sendBackKeyEvent(KeyEvent.ACTION_DOWN, false);
|
||||
mNavButtonController.sendBackKeyEvent(KeyEvent.ACTION_UP, true);
|
||||
@@ -365,6 +369,7 @@ public class TaskbarNavButtonControllerTest {
|
||||
@Test
|
||||
@RequiresFlagsEnabled(FLAG_PREDICTIVE_BACK_THREE_BUTTON_NAV)
|
||||
public void testButtonsDisabledWhileBackPressed() {
|
||||
mNavButtonController.init(mockTaskbarControllers);
|
||||
mNavButtonController.sendBackKeyEvent(KeyEvent.ACTION_DOWN, false);
|
||||
mNavButtonController.onButtonClick(BUTTON_HOME, mockView);
|
||||
mNavButtonController.onButtonClick(BUTTON_RECENTS, mockView);
|
||||
@@ -377,6 +382,14 @@ public class TaskbarNavButtonControllerTest {
|
||||
verify(mockSystemUiProxy, never()).onImeSwitcherPressed();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnRecentsButtonLayoutChanged() {
|
||||
Rect rect = new Rect(10, 20, 30, 40);
|
||||
mNavButtonController.init(mockTaskbarControllers);
|
||||
mNavButtonController.onRecentsButtonLayoutChanged(rect);
|
||||
verify(mockSystemUiProxy).notifyRecentsButtonPositionChanged(eq(rect));
|
||||
}
|
||||
|
||||
private void verifyKeyEvent(KeyEvent keyEvent, int action, boolean isCancelled) {
|
||||
assertEquals(isCancelled, keyEvent.isCanceled());
|
||||
assertEquals(action, KeyEvent.ACTION_DOWN, keyEvent.getAction());
|
||||
|
||||
+274
-26
@@ -17,24 +17,31 @@
|
||||
package com.android.launcher3.taskbar
|
||||
|
||||
import android.animation.AnimatorTestRule
|
||||
import android.app.WindowConfiguration
|
||||
import android.content.ComponentName
|
||||
import android.content.Intent
|
||||
import android.os.Process
|
||||
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
|
||||
import androidx.test.core.app.ApplicationProvider
|
||||
import com.android.launcher3.BubbleTextView
|
||||
import com.android.launcher3.Flags.FLAG_ENABLE_MULTI_INSTANCE_MENU_TASKBAR
|
||||
import com.android.launcher3.Flags.FLAG_TASKBAR_OVERFLOW
|
||||
import com.android.launcher3.R
|
||||
import com.android.launcher3.dagger.LauncherAppSingleton
|
||||
import com.android.launcher3.dagger.LauncherComponentProvider.appComponent
|
||||
import com.android.launcher3.model.BgDataModel
|
||||
import com.android.launcher3.model.data.ItemInfo
|
||||
import com.android.launcher3.model.data.TaskItemInfo
|
||||
import com.android.launcher3.model.data.WorkspaceData
|
||||
import com.android.launcher3.model.data.WorkspaceItemInfo
|
||||
import com.android.launcher3.popup.SystemShortcut
|
||||
import com.android.launcher3.statehandlers.DesktopVisibilityController
|
||||
import com.android.launcher3.taskbar.TaskbarControllerTestUtil.runOnMainSync
|
||||
import com.android.launcher3.taskbar.TaskbarViewTestUtil.createHotseatItems
|
||||
import com.android.launcher3.taskbar.bubbles.BubbleBarViewController
|
||||
import com.android.launcher3.taskbar.bubbles.stashing.BubbleStashController
|
||||
import com.android.launcher3.taskbar.rules.DisplayControllerModule
|
||||
import com.android.launcher3.taskbar.rules.AllTaskbarSandboxModules
|
||||
import com.android.launcher3.taskbar.rules.MockedRecentsModelHelper
|
||||
import com.android.launcher3.taskbar.rules.MockedRecentsModelTestRule
|
||||
import com.android.launcher3.taskbar.rules.SandboxParams
|
||||
@@ -46,22 +53,27 @@ import com.android.launcher3.taskbar.rules.TaskbarSandboxComponent
|
||||
import com.android.launcher3.taskbar.rules.TaskbarUnitTestRule
|
||||
import com.android.launcher3.taskbar.rules.TaskbarUnitTestRule.InjectController
|
||||
import com.android.launcher3.taskbar.rules.TaskbarWindowSandboxContext
|
||||
import com.android.launcher3.util.AllModulesForTest
|
||||
import com.android.launcher3.util.FakePrefsModule
|
||||
import com.android.launcher3.util.LauncherMultivalentJUnit
|
||||
import com.android.launcher3.util.LauncherMultivalentJUnit.EmulatedDevices
|
||||
import com.android.launcher3.util.Preconditions.assertNotNull
|
||||
import com.android.launcher3.util.TestUtil.getOnUiThread
|
||||
import com.android.quickstep.RecentsModel
|
||||
import com.android.quickstep.SystemUiProxy
|
||||
import com.android.quickstep.util.DesktopTask
|
||||
import com.android.quickstep.util.GroupTask
|
||||
import com.android.quickstep.util.SingleTask
|
||||
import com.android.quickstep.util.SingleTask.Companion.createTaskItemInfo
|
||||
import com.android.systemui.shared.recents.model.Task
|
||||
import com.android.window.flags.Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MODE
|
||||
import com.android.window.flags.Flags.FLAG_ENABLE_DESKTOP_WINDOWING_TASKBAR_RUNNING_APPS
|
||||
import com.android.window.flags2.Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MODE
|
||||
import com.android.window.flags2.Flags.FLAG_ENABLE_DESKTOP_WINDOWING_TASKBAR_RUNNING_APPS
|
||||
import com.android.window.flags2.Flags.FLAG_ENABLE_PINNING_APP_WITH_CONTEXT_MENU
|
||||
import com.android.window.flags2.Flags.FLAG_ENABLE_TASKBAR_OVERFLOW
|
||||
import com.android.wm.shell.Flags.FLAG_ENABLE_BUBBLE_BAR
|
||||
import com.android.wm.shell.desktopmode.IDesktopTaskListener
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import dagger.BindsInstance
|
||||
import dagger.Component
|
||||
import java.util.function.Predicate
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
@@ -74,10 +86,10 @@ import org.mockito.kotlin.whenever
|
||||
@RunWith(LauncherMultivalentJUnit::class)
|
||||
@EmulatedDevices(["pixelTablet2023"])
|
||||
@EnableFlags(
|
||||
FLAG_TASKBAR_OVERFLOW,
|
||||
FLAG_ENABLE_DESKTOP_WINDOWING_TASKBAR_RUNNING_APPS,
|
||||
FLAG_ENABLE_DESKTOP_WINDOWING_MODE,
|
||||
FLAG_ENABLE_BUBBLE_BAR,
|
||||
FLAG_ENABLE_TASKBAR_OVERFLOW,
|
||||
)
|
||||
@DisableFlags(FLAG_ENABLE_MULTI_INSTANCE_MENU_TASKBAR)
|
||||
class TaskbarOverflowTest {
|
||||
@@ -116,7 +128,14 @@ class TaskbarOverflowTest {
|
||||
@InjectController lateinit var bubbleStashController: BubbleStashController
|
||||
@InjectController lateinit var keyboardQuickSwitchController: KeyboardQuickSwitchController
|
||||
|
||||
private val desktopVisibilityController: DesktopVisibilityController
|
||||
get() = DesktopVisibilityController.INSTANCE[context]
|
||||
|
||||
private var desktopTaskListener: IDesktopTaskListener? = null
|
||||
private val modelCallback = ModelCallbacks()
|
||||
|
||||
private val taskbarContext: TaskbarActivityContext
|
||||
get() = taskbarUnitTestRule.activityContext
|
||||
|
||||
private var currentControllerInitCallback: () -> Unit = {}
|
||||
set(value) {
|
||||
@@ -129,7 +148,10 @@ class TaskbarOverflowTest {
|
||||
if (!recentAppsController.canShowRunningApps) {
|
||||
recentAppsController.onDestroy()
|
||||
recentAppsController.canShowRunningApps = true
|
||||
recentAppsController.init(taskbarUnitTestRule.activityContext.controllers)
|
||||
recentAppsController.init(
|
||||
taskbarUnitTestRule.activityContext.controllers,
|
||||
emptyList(),
|
||||
)
|
||||
}
|
||||
|
||||
currentControllerInitCallback.invoke()
|
||||
@@ -138,6 +160,7 @@ class TaskbarOverflowTest {
|
||||
|
||||
@Before
|
||||
fun ensureRunningAppsShowing() {
|
||||
whenever(desktopVisibilityController.isInDesktopMode(context.displayId)).thenReturn(true)
|
||||
runOnMainSync { recentsModel.resolvePendingTaskRequests() }
|
||||
}
|
||||
|
||||
@@ -346,6 +369,8 @@ class TaskbarOverflowTest {
|
||||
createDesktopTask(createdTasks)
|
||||
|
||||
assertThat(taskbarOverflowIconIndex).isEqualTo(initialIconCount)
|
||||
assertThat(getOverflowIconTooltipText()).isEqualTo("Other recent apps")
|
||||
|
||||
tapOverflowIcon()
|
||||
// Keyboard quick switch view is shown only after list of recent task is asynchronously
|
||||
// retrieved from the recents model.
|
||||
@@ -353,10 +378,12 @@ class TaskbarOverflowTest {
|
||||
|
||||
assertThat(getOnUiThread { keyboardQuickSwitchController.isShownFromTaskbar }).isTrue()
|
||||
assertThat(getOnUiThread { keyboardQuickSwitchController.shownTaskIds() })
|
||||
.containsExactlyElementsIn(0..<createdTasks)
|
||||
.containsExactlyElementsIn(0..targetOverflowSize)
|
||||
assertThat(getOverflowIconTooltipText()).isNull()
|
||||
|
||||
tapOverflowIcon()
|
||||
assertThat(keyboardQuickSwitchController.isShown).isFalse()
|
||||
assertThat(getOverflowIconTooltipText()).isEqualTo("Other recent apps")
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -425,7 +452,167 @@ class TaskbarOverflowTest {
|
||||
|
||||
assertThat(getOnUiThread { keyboardQuickSwitchController.isShownFromTaskbar }).isTrue()
|
||||
assertThat(getOnUiThread { keyboardQuickSwitchController.shownTaskIds() })
|
||||
.containsExactlyElementsIn(listOf(0) + (2..<createdTasks).toList())
|
||||
.containsExactlyElementsIn(listOf(0) + (2..targetOverflowSize + 1).toList())
|
||||
}
|
||||
|
||||
@Test
|
||||
@TaskbarMode(PINNED)
|
||||
fun testFullscreenTasksNotShownInKQS() {
|
||||
val maxNumIconViews = maxNumberOfTaskbarIcons
|
||||
// Assume there are at least all apps and divider icon, as they would appear once running
|
||||
// apps are added, even if not present initially.
|
||||
val initialIconCount = currentNumberOfTaskbarIcons.coerceAtLeast(2)
|
||||
val hotseatItems = createHotseatItems(1)
|
||||
|
||||
val targetOverflowSize = 5
|
||||
val createdTasks = maxNumIconViews - initialIconCount + targetOverflowSize
|
||||
createFullscreenAndDesktopTasksFromPackages(
|
||||
listOf("fakeFullscreen"),
|
||||
listOf("fake") +
|
||||
listOf(hotseatItems[0]?.targetPackage ?: "") +
|
||||
List(createdTasks - 2) { "fake" },
|
||||
)
|
||||
|
||||
runOnMainSync {
|
||||
val taskbarView: TaskbarView =
|
||||
taskbarUnitTestRule.activityContext.dragLayer.findViewById(R.id.taskbar_view)
|
||||
taskbarView.updateItems(
|
||||
recentAppsController.updateHotseatItemInfos(hotseatItems as Array<ItemInfo?>),
|
||||
recentAppsController.shownTasks,
|
||||
)
|
||||
}
|
||||
|
||||
tapOverflowIcon()
|
||||
// Keyboard quick switch view is shown only after list of recent task is asynchronously
|
||||
// retrieved from the recents model.
|
||||
runOnMainSync { recentsModel.resolvePendingTaskRequests() }
|
||||
|
||||
assertThat(getOnUiThread { keyboardQuickSwitchController.isShownFromTaskbar }).isTrue()
|
||||
// Taskbar is in overflow by `targetOverflowSize`, so overflow UI should have
|
||||
// `targetOverflowSize + 1` items, to account for a spot in taskbar taken by the overflow
|
||||
// icon. Task IDs for running desktop apps start at 1 - 0 is used for fullscreen task.
|
||||
assertThat(getOnUiThread { keyboardQuickSwitchController.shownTaskIds() })
|
||||
.containsExactlyElementsIn(listOf(1) + (3..targetOverflowSize + 2).toList())
|
||||
}
|
||||
|
||||
@Test
|
||||
@TaskbarMode(PINNED)
|
||||
@EnableFlags(FLAG_ENABLE_PINNING_APP_WITH_CONTEXT_MENU)
|
||||
fun pinToTaskbarShortcut_unpinPinnedItem() {
|
||||
// Create two tasks and two pinned items.
|
||||
createDesktopTask(2)
|
||||
val hotseatItems = createHotseatItems(2)
|
||||
var shortcut: SystemShortcut<*>? = null
|
||||
var hotseatIcon: BubbleTextView? = null
|
||||
runOnMainSync {
|
||||
val taskbarView = setUpTaskbarAndModelCallback(hotseatItems)
|
||||
hotseatIcon =
|
||||
taskbarView.iconViews.filterIsInstance<BubbleTextView>().first {
|
||||
it.tag is WorkspaceItemInfo
|
||||
}
|
||||
shortcut =
|
||||
taskbarContext.controllers.taskbarPopupController.createPinShortcut(
|
||||
taskbarContext,
|
||||
hotseatIcon!!.tag as ItemInfo,
|
||||
hotseatIcon,
|
||||
) as SystemShortcut<*>
|
||||
}
|
||||
assertNotNull(shortcut)
|
||||
runOnMainSync { shortcut?.onClick(hotseatIcon) }
|
||||
// After unpinning the first item, only the second app is left.
|
||||
assertThat(modelCallback.hotseatItems.map { info -> info.title })
|
||||
.isEqualTo(listOf("Test App 1"))
|
||||
// The unpinned app doesn't have a task so the shown tasks won't change.
|
||||
assertThat(recentAppsController.shownTasks.map { it.tasks[0].key.id })
|
||||
.isEqualTo(listOf(0, 1))
|
||||
}
|
||||
|
||||
@Test
|
||||
@TaskbarMode(PINNED)
|
||||
@EnableFlags(FLAG_ENABLE_PINNING_APP_WITH_CONTEXT_MENU)
|
||||
fun pinToTaskbarShortcut_unpinPinnedItemWithTask() {
|
||||
// Create two hotseat items with a task for both of them respectively.
|
||||
var hotseatItems =
|
||||
createHotseatItems(2).mapIndexed { idx, item -> TaskItemInfo(idx, item) }.toTypedArray()
|
||||
createDesktopTaskWithTasksFromPackages(hotseatItems.mapNotNull { it.targetPackage })
|
||||
var shortcut: SystemShortcut<*>? = null
|
||||
var hotseatIcon: BubbleTextView? = null
|
||||
runOnMainSync {
|
||||
val taskbarView = setUpTaskbarAndModelCallback(hotseatItems.map { it }.toTypedArray())
|
||||
hotseatIcon =
|
||||
taskbarView.iconViews.filterIsInstance<BubbleTextView>().first {
|
||||
it.tag is WorkspaceItemInfo
|
||||
}
|
||||
shortcut =
|
||||
taskbarContext.controllers.taskbarPopupController.createPinShortcut(
|
||||
taskbarContext,
|
||||
hotseatIcon!!.tag as ItemInfo,
|
||||
hotseatIcon,
|
||||
) as SystemShortcut<*>
|
||||
}
|
||||
// Before unpinning the app, both of the apps should be pinned and no shown task available.
|
||||
assertThat(modelCallback.hotseatItems.map { info -> info.title })
|
||||
.isEqualTo(listOf("Test App 0", "Test App 1"))
|
||||
assertThat(recentAppsController.shownTasks.map { it.tasks[0].key.id })
|
||||
.isEqualTo(emptyList<Int>())
|
||||
assertNotNull(shortcut)
|
||||
runOnMainSync { shortcut?.onClick(hotseatIcon) }
|
||||
// After unpinning the app, app 0 is removed and its task is shown as a recent task.
|
||||
assertThat(modelCallback.hotseatItems.map { info -> info.title })
|
||||
.isEqualTo(listOf("Test App 1"))
|
||||
assertThat(recentAppsController.shownTasks.map { it.tasks[0].key.id }).isEqualTo(listOf(0))
|
||||
}
|
||||
|
||||
@Test
|
||||
@TaskbarMode(PINNED)
|
||||
@EnableFlags(FLAG_ENABLE_PINNING_APP_WITH_CONTEXT_MENU)
|
||||
fun pinToTaskbarShortcut_pinRecentTask() {
|
||||
// Create two tasks and two pinned items.
|
||||
createDesktopTask(2)
|
||||
val hotseatItems = createHotseatItems(2)
|
||||
|
||||
var shortcut: SystemShortcut<*>? = null
|
||||
var recentTaskIcon: BubbleTextView? = null
|
||||
runOnMainSync {
|
||||
val taskbarView = setUpTaskbarAndModelCallback(hotseatItems)
|
||||
// Get the first recent task icon
|
||||
recentTaskIcon =
|
||||
taskbarView.iconViews.filterIsInstance<BubbleTextView>().first {
|
||||
it.tag is GroupTask
|
||||
}
|
||||
val recentTaskInfo =
|
||||
createTaskItemInfo(
|
||||
recentTaskIcon!!.tag as SingleTask,
|
||||
WorkspaceItemInfo().apply {
|
||||
title = "Test App 2"
|
||||
intent = Intent().apply { `package` = "fake" }
|
||||
},
|
||||
)
|
||||
shortcut =
|
||||
taskbarContext.controllers.taskbarPopupController.createPinShortcut(
|
||||
taskbarContext,
|
||||
recentTaskInfo,
|
||||
recentTaskIcon,
|
||||
) as SystemShortcut<*>
|
||||
}
|
||||
assertNotNull(shortcut)
|
||||
runOnMainSync { shortcut?.onClick(recentTaskIcon) }
|
||||
|
||||
// After pinning the recent task, it should be included in the hotseat items.
|
||||
assertThat(modelCallback.hotseatItems.map { info -> info.title })
|
||||
.isEqualTo(listOf("Test App 0", "Test App 1", "Test App 2"))
|
||||
// As the task is pinned, the shown tasks should remove it from the list
|
||||
assertThat(recentAppsController.shownTasks.map { it.tasks[0].key.id }).isEqualTo(listOf(1))
|
||||
}
|
||||
|
||||
private fun setUpTaskbarAndModelCallback(hotseatItems: Array<WorkspaceItemInfo>): TaskbarView {
|
||||
val taskbarView: TaskbarView =
|
||||
taskbarUnitTestRule.activityContext.dragLayer.findViewById(R.id.taskbar_view)
|
||||
taskbarView.updateItems(hotseatItems, recentAppsController.shownTasks)
|
||||
modelCallback.recentAppsController = recentAppsController
|
||||
context.baseContext.appComponent.launcherAppState.model.addCallbacks(modelCallback)
|
||||
modelCallback.bindItemsAdded(hotseatItems.toList())
|
||||
return taskbarView
|
||||
}
|
||||
|
||||
private fun createDesktopTask(tasksToAdd: Int) {
|
||||
@@ -433,12 +620,36 @@ class TaskbarOverflowTest {
|
||||
}
|
||||
|
||||
private fun createDesktopTaskWithTasksFromPackages(packages: List<String>) {
|
||||
val tasks =
|
||||
packages.mapIndexed({ index, p ->
|
||||
createFullscreenAndDesktopTasksFromPackages(emptyList(), packages)
|
||||
}
|
||||
|
||||
private fun createFullscreenAndDesktopTasksFromPackages(
|
||||
fullscreenPackages: List<String>,
|
||||
desktopPackages: List<String>,
|
||||
) {
|
||||
val defaultDisplayId = context.displayId
|
||||
val tasks: List<GroupTask> =
|
||||
fullscreenPackages.mapIndexed({ index, p ->
|
||||
SingleTask(
|
||||
Task(
|
||||
Task.TaskKey(
|
||||
index,
|
||||
WindowConfiguration.WINDOWING_MODE_FULLSCREEN,
|
||||
Intent().apply { `package` = p },
|
||||
ComponentName(p, ""),
|
||||
Process.myUserHandle().identifier,
|
||||
2000,
|
||||
)
|
||||
)
|
||||
)
|
||||
})
|
||||
|
||||
val desktopTasks =
|
||||
desktopPackages.mapIndexed({ index, p ->
|
||||
Task(
|
||||
Task.TaskKey(
|
||||
index,
|
||||
0,
|
||||
index + fullscreenPackages.size,
|
||||
WindowConfiguration.WINDOWING_MODE_FREEFORM,
|
||||
Intent().apply { `package` = p },
|
||||
ComponentName(p, ""),
|
||||
Process.myUserHandle().identifier,
|
||||
@@ -447,12 +658,11 @@ class TaskbarOverflowTest {
|
||||
)
|
||||
})
|
||||
|
||||
recentsModel.updateRecentTasks(listOf(DesktopTask(deskId = 0, DEFAULT_DISPLAY, tasks)))
|
||||
for (task in 1..tasks.size) {
|
||||
desktopTaskListener?.onTasksVisibilityChanged(
|
||||
context.virtualDisplay.display.displayId,
|
||||
task,
|
||||
)
|
||||
recentsModel.updateRecentTasks(
|
||||
tasks + listOf(DesktopTask(deskId = 0, defaultDisplayId, desktopTasks))
|
||||
)
|
||||
for (task in 1..desktopTasks.size) {
|
||||
desktopTaskListener?.onTasksVisibilityChanged(defaultDisplayId, task)
|
||||
}
|
||||
runOnMainSync { recentsModel.resolvePendingTaskRequests() }
|
||||
}
|
||||
@@ -482,7 +692,8 @@ class TaskbarOverflowTest {
|
||||
return getOnUiThread {
|
||||
val iconLayoutBounds =
|
||||
taskbarViewController.transientTaskbarIconLayoutBoundsInParent
|
||||
val availableWidth = taskbarUnitTestRule.activityContext.deviceProfile.widthPx
|
||||
val availableWidth =
|
||||
taskbarUnitTestRule.activityContext.deviceProfile.deviceProperties.widthPx
|
||||
iconLayoutBounds.left - (availableWidth - iconLayoutBounds.right) < 2
|
||||
}
|
||||
}
|
||||
@@ -490,7 +701,7 @@ class TaskbarOverflowTest {
|
||||
private val taskbarEndMargin: Int
|
||||
get() {
|
||||
return getOnUiThread {
|
||||
taskbarUnitTestRule.activityContext.deviceProfile.widthPx -
|
||||
taskbarUnitTestRule.activityContext.deviceProfile.deviceProperties.widthPx -
|
||||
taskbarViewController.transientTaskbarIconLayoutBoundsInParent.right
|
||||
}
|
||||
}
|
||||
@@ -517,6 +728,14 @@ class TaskbarOverflowTest {
|
||||
}
|
||||
}
|
||||
|
||||
private fun getOverflowIconTooltipText(): String? {
|
||||
return getOnUiThread {
|
||||
val overflowIcon =
|
||||
taskbarViewController.iconViews.firstOrNull { it is TaskbarOverflowView }
|
||||
(overflowIcon as? TaskbarOverflowView)?.getTextForTooltipPopup()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds enough running apps for taskbar to enter overflow of `targetOverflowSize`, and verifies
|
||||
* * max number of icons in the taskbar remains unchanged
|
||||
@@ -544,13 +763,42 @@ class TaskbarOverflowTest {
|
||||
}
|
||||
return maxNumIconViews
|
||||
}
|
||||
|
||||
private class ModelCallbacks : BgDataModel.Callbacks {
|
||||
var hotseatItems = mutableListOf<WorkspaceItemInfo>()
|
||||
var recentAppsController: TaskbarRecentAppsController? = null
|
||||
|
||||
override fun bindCompleteModel(itemIdMap: WorkspaceData, isBindingSync: Boolean) =
|
||||
bindItemsAdded(itemIdMap.toList())
|
||||
|
||||
override fun bindItemsAdded(items: List<ItemInfo>) {
|
||||
runOnMainSync {
|
||||
items
|
||||
.filter { item ->
|
||||
item is WorkspaceItemInfo &&
|
||||
!hotseatItems.any { it.targetPackage == item.targetPackage }
|
||||
}
|
||||
.forEach { item -> hotseatItems.add(item as WorkspaceItemInfo) }
|
||||
recentAppsController?.updateHotseatItemInfos(hotseatItems.toTypedArray())
|
||||
}
|
||||
}
|
||||
|
||||
override fun bindWorkspaceComponentsRemoved(matcher: Predicate<ItemInfo?>) {
|
||||
runOnMainSync {
|
||||
for (i in hotseatItems.size - 1 downTo 0) {
|
||||
if (matcher.test(hotseatItems[i])) {
|
||||
hotseatItems.removeAt(i)
|
||||
}
|
||||
}
|
||||
recentAppsController?.updateHotseatItemInfos(hotseatItems.toTypedArray())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** TaskbarOverflowComponent used to bind the RecentsModel. */
|
||||
@LauncherAppSingleton
|
||||
@Component(
|
||||
modules = [AllModulesForTest::class, FakePrefsModule::class, DisplayControllerModule::class]
|
||||
)
|
||||
@Component(modules = [AllTaskbarSandboxModules::class])
|
||||
interface TaskbarOverflowComponent : TaskbarSandboxComponent {
|
||||
|
||||
@Component.Builder
|
||||
|
||||
+63
-2
@@ -16,32 +16,44 @@
|
||||
|
||||
package com.android.launcher3.taskbar
|
||||
|
||||
import android.content.ComponentName
|
||||
import android.content.Intent
|
||||
import android.platform.test.annotations.DisableFlags
|
||||
import android.platform.test.annotations.EnableFlags
|
||||
import android.platform.test.flag.junit.SetFlagsRule
|
||||
import android.util.SparseArray
|
||||
import com.android.launcher3.AbstractFloatingView
|
||||
import com.android.launcher3.BubbleTextView
|
||||
import com.android.launcher3.Flags.FLAG_ENABLE_MULTI_INSTANCE_MENU_TASKBAR
|
||||
import com.android.launcher3.Flags.FLAG_ENABLE_PINNING_APP_WITH_CONTEXT_MENU
|
||||
import com.android.launcher3.LauncherSettings
|
||||
import com.android.launcher3.R
|
||||
import com.android.launcher3.model.data.AppInfo
|
||||
import com.android.launcher3.model.data.ItemInfo
|
||||
import com.android.launcher3.model.data.WorkspaceItemInfo
|
||||
import com.android.launcher3.statehandlers.DesktopVisibilityController
|
||||
import com.android.launcher3.taskbar.TaskbarControllerTestUtil.runOnMainSync
|
||||
import com.android.launcher3.taskbar.TaskbarViewTestUtil.createHotseatWorkspaceItem
|
||||
import com.android.launcher3.taskbar.TaskbarViewTestUtil.createRecents
|
||||
import com.android.launcher3.taskbar.TaskbarViewTestUtil.createTestWorkspaceItem
|
||||
import com.android.launcher3.taskbar.rules.TaskbarUnitTestRule
|
||||
import com.android.launcher3.taskbar.rules.TaskbarUnitTestRule.InjectController
|
||||
import com.android.launcher3.taskbar.rules.TaskbarWindowSandboxContext
|
||||
import com.android.launcher3.util.LauncherMultivalentJUnit
|
||||
import com.android.launcher3.util.LauncherMultivalentJUnit.EmulatedDevices
|
||||
import com.android.quickstep.util.GroupTask
|
||||
import com.android.window.flags2.Flags.FLAG_ENABLE_PINNING_APP_WITH_CONTEXT_MENU
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import org.junit.Assert
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Mockito
|
||||
import org.mockito.kotlin.whenever
|
||||
|
||||
@RunWith(LauncherMultivalentJUnit::class)
|
||||
@EmulatedDevices(["pixelFoldable2023", "pixelTablet2023"])
|
||||
@DisableFlags(FLAG_ENABLE_MULTI_INSTANCE_MENU_TASKBAR, FLAG_ENABLE_PINNING_APP_WITH_CONTEXT_MENU)
|
||||
@DisableFlags(FLAG_ENABLE_MULTI_INSTANCE_MENU_TASKBAR)
|
||||
class TaskbarPopupControllerTest {
|
||||
@get:Rule(order = 0) val setFlagsRule = SetFlagsRule()
|
||||
|
||||
@@ -54,6 +66,9 @@ class TaskbarPopupControllerTest {
|
||||
private val taskbarContext: TaskbarActivityContext
|
||||
get() = taskbarUnitTestRule.activityContext
|
||||
|
||||
private val desktopVisibilityController: DesktopVisibilityController
|
||||
get() = DesktopVisibilityController.INSTANCE[context]
|
||||
|
||||
private lateinit var taskbarView: TaskbarView
|
||||
private lateinit var hotseatIcon: BubbleTextView
|
||||
private lateinit var recentTaskIcon: BubbleTextView
|
||||
@@ -64,6 +79,12 @@ class TaskbarPopupControllerTest {
|
||||
runOnMainSync { taskbarView = taskbarContext.dragLayer.findViewById(R.id.taskbar_view) }
|
||||
|
||||
val hotseatItems = arrayOf(createHotseatWorkspaceItem())
|
||||
popupController.setApps(
|
||||
hotseatItems
|
||||
.map { item -> AppInfo(item.targetComponent, item.title, item.user, item.intent) }
|
||||
.toTypedArray()
|
||||
)
|
||||
popupController.setHotseatInfosList(SparseArray())
|
||||
val recentItems = createRecents(2)
|
||||
runOnMainSync {
|
||||
taskbarView.updateItems(hotseatItems, recentItems)
|
||||
@@ -86,12 +107,52 @@ class TaskbarPopupControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(FLAG_ENABLE_PINNING_APP_WITH_CONTEXT_MENU)
|
||||
fun showForIcon_recentTask() {
|
||||
whenever(desktopVisibilityController.isInDesktopMode(context.displayId)).thenReturn(true)
|
||||
assertThat(hasPopupMenu()).isFalse()
|
||||
runOnMainSync { popupController.showForIcon(recentTaskIcon) }
|
||||
assertThat(hasPopupMenu()).isTrue()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun createPinShortcut_itemAlreadyPinned_returnsUnpinShortcut() {
|
||||
val hotseatItems = SparseArray<ItemInfo>()
|
||||
val appUser = android.os.Process.myUserHandle()
|
||||
val appAIntent = Intent().setComponent(ComponentName("com.example.app", "AppAActivity"))
|
||||
|
||||
val itemFromAllApps =
|
||||
createTestWorkspaceItem(
|
||||
0,
|
||||
"AppA",
|
||||
appAIntent,
|
||||
appUser,
|
||||
LauncherSettings.Favorites.CONTAINER_ALL_APPS,
|
||||
)
|
||||
|
||||
val pinnedItemInHotseat =
|
||||
createTestWorkspaceItem(
|
||||
1,
|
||||
"AppA",
|
||||
appAIntent,
|
||||
appUser,
|
||||
LauncherSettings.Favorites.CONTAINER_HOTSEAT,
|
||||
)
|
||||
|
||||
hotseatItems.put(0, pinnedItemInHotseat)
|
||||
popupController.setHotseatInfosList(hotseatItems)
|
||||
val allAppsAppIcon = Mockito.mock(BubbleTextView::class.java)
|
||||
|
||||
val shortcut =
|
||||
popupController.createPinShortcut(taskbarContext, itemFromAllApps, allAppsAppIcon)
|
||||
Assert.assertNotNull("Shortcut should not be null", shortcut)
|
||||
Assert.assertTrue(
|
||||
"Shortcut should be PinToTaskbarShortcut",
|
||||
shortcut is PinToTaskbarShortcut<*>,
|
||||
)
|
||||
Assert.assertFalse((shortcut as PinToTaskbarShortcut<*>).mIsPin)
|
||||
}
|
||||
|
||||
private fun hasPopupMenu(): Boolean {
|
||||
return AbstractFloatingView.hasOpenView(
|
||||
taskbarContext,
|
||||
|
||||
+356
-27
@@ -24,7 +24,9 @@ import android.content.res.Resources
|
||||
import android.graphics.Rect
|
||||
import android.os.Process
|
||||
import android.os.UserHandle
|
||||
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
|
||||
import androidx.test.annotation.UiThreadTest
|
||||
import com.android.internal.R
|
||||
@@ -38,7 +40,6 @@ import com.android.launcher3.model.data.TaskItemInfo
|
||||
import com.android.launcher3.model.data.WorkspaceItemInfo
|
||||
import com.android.launcher3.taskbar.TaskbarRecentAppsController.TaskState
|
||||
import com.android.launcher3.util.LauncherMultivalentJUnit
|
||||
import com.android.launcher3.util.SplitConfigurationOptions
|
||||
import com.android.quickstep.RecentsModel
|
||||
import com.android.quickstep.RecentsModel.RecentTasksChangedListener
|
||||
import com.android.quickstep.TaskIconCache
|
||||
@@ -47,6 +48,7 @@ import com.android.quickstep.util.GroupTask
|
||||
import com.android.quickstep.util.SingleTask
|
||||
import com.android.quickstep.util.SplitTask
|
||||
import com.android.systemui.shared.recents.model.Task
|
||||
import com.android.wm.shell.shared.split.SplitBounds
|
||||
import com.android.wm.shell.shared.split.SplitScreenConstants
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import java.util.function.Consumer
|
||||
@@ -60,6 +62,7 @@ import org.mockito.ArgumentCaptor
|
||||
import org.mockito.Mock
|
||||
import org.mockito.junit.MockitoJUnit
|
||||
import org.mockito.kotlin.any
|
||||
import org.mockito.kotlin.argumentCaptor
|
||||
import org.mockito.kotlin.doAnswer
|
||||
import org.mockito.kotlin.never
|
||||
import org.mockito.kotlin.times
|
||||
@@ -72,6 +75,7 @@ import org.mockito.kotlin.whenever
|
||||
class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() {
|
||||
|
||||
@get:Rule val mockitoRule = MockitoJUnit.rule()
|
||||
@get:Rule val setFlagsRule = SetFlagsRule()
|
||||
@get:Rule
|
||||
val disableControllerForCertainTestsWatcher =
|
||||
object : TestWatcher() {
|
||||
@@ -111,14 +115,25 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() {
|
||||
whenever(mockResources.getBoolean(R.bool.config_isDesktopModeSupported)).thenReturn(true)
|
||||
|
||||
whenever(mockRecentsModel.iconCache).thenReturn(mockIconCache)
|
||||
whenever(mockRecentsModel.unregisterRecentTasksChangedListener()).then {
|
||||
whenever(mockRecentsModel.unregisterRecentTasksChangedListener(any())).then {
|
||||
recentTasksChangedListener = null
|
||||
it
|
||||
}
|
||||
whenever(taskbarDesktopModeController.isLauncherAnimationRunning).thenReturn(false)
|
||||
recentAppsController = TaskbarRecentAppsController(mockContext, mockRecentsModel)
|
||||
recentAppsController.canShowRunningApps = canShowRunningAndRecentAppsAtInit
|
||||
recentAppsController.canShowRecentApps = canShowRunningAndRecentAppsAtInit
|
||||
recentAppsController.init(taskbarControllers)
|
||||
|
||||
// To ensure the initial getTasks() call is not seen as "loading" for the rest of the test,
|
||||
// execute its callback.
|
||||
doAnswer {
|
||||
val callback: Consumer<ArrayList<GroupTask>> = it.getArgument(1)
|
||||
callback.accept(arrayListOf())
|
||||
taskListChangeId
|
||||
}
|
||||
.whenever(mockRecentsModel)
|
||||
.getTasks(any(), any<Consumer<List<GroupTask>>>())
|
||||
recentAppsController.init(taskbarControllers, emptyList())
|
||||
taskbarControllers.onPostInit()
|
||||
|
||||
recentTasksChangedListener =
|
||||
@@ -148,13 +163,13 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() {
|
||||
runningTasks = listOf(createTask(1, RUNNING_APP_PACKAGE_1)),
|
||||
recentTaskPackages = listOf(RECENT_PACKAGE_1, RECENT_PACKAGE_2),
|
||||
)
|
||||
verify(mockRecentsModel, never()).getTasks(any<Consumer<List<GroupTask>>>())
|
||||
verify(mockRecentsModel, never()).getTasks(any(), any<Consumer<List<GroupTask>>>())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun canShowRunningAndRecentAppsIsFalseAfterInit_getTasksOnlyCalledInInit() {
|
||||
// getTasks() should have been called once from init().
|
||||
verify(mockRecentsModel, times(1)).getTasks(any<Consumer<List<GroupTask>>>(), any())
|
||||
verify(mockRecentsModel, times(1)).getTasks(any(), any<Consumer<List<GroupTask>>>())
|
||||
recentAppsController.canShowRunningApps = false
|
||||
recentAppsController.canShowRecentApps = false
|
||||
prepareHotseatAndRunningAndRecentApps(
|
||||
@@ -163,7 +178,83 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() {
|
||||
recentTaskPackages = listOf(RECENT_PACKAGE_1, RECENT_PACKAGE_2),
|
||||
)
|
||||
// Verify that getTasks() was not called again after the init().
|
||||
verify(mockRecentsModel, times(1)).getTasks(any<Consumer<List<GroupTask>>>(), any())
|
||||
verify(mockRecentsModel, times(1)).getTasks(any(), any<Consumer<List<GroupTask>>>())
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(com.android.window.flags2.Flags.FLAG_ENABLE_TASKBAR_RECENT_TASKS_THROTTLE_BUGFIX)
|
||||
fun recentTasksChanged_duringGetTasksLoading_dontCallGetTasks() {
|
||||
// getTasks() should have been called once from init().
|
||||
verify(mockRecentsModel, times(1)).getTasks(any(), any<Consumer<List<GroupTask>>>())
|
||||
// Override the mock answer for getTasks() so it doesn't call the callback immediately.
|
||||
doAnswer { taskListChangeId }
|
||||
.whenever(mockRecentsModel)
|
||||
.getTasks(any(), any<Consumer<List<GroupTask>>>())
|
||||
recentTasksChangedListener?.onRecentTasksChanged()
|
||||
// By not invoking the callback passed to getTasks() we here emulate getTasks() loading.
|
||||
|
||||
recentTasksChangedListener?.onRecentTasksChanged()
|
||||
|
||||
// getTasks() is only called two times overall (init + once more).
|
||||
verify(mockRecentsModel, times(2)).getTasks(any(), any<Consumer<List<GroupTask>>>())
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(com.android.window.flags2.Flags.FLAG_ENABLE_TASKBAR_RECENT_TASKS_THROTTLE_BUGFIX)
|
||||
fun recentTasksChanged_duringGetTasksLoading_getTasksCalledWhenLoadingDone() {
|
||||
val callbackCaptor = argumentCaptor<Consumer<List<GroupTask>>>()
|
||||
// getTasks() should have been called once from init().
|
||||
verify(mockRecentsModel, times(1)).getTasks(any(), callbackCaptor.capture())
|
||||
// Override the mock answer for getTasks() so it doesn't call the callback immediately.
|
||||
doAnswer { taskListChangeId }
|
||||
.whenever(mockRecentsModel)
|
||||
.getTasks(any(), any<Consumer<List<GroupTask>>>())
|
||||
recentTasksChangedListener?.onRecentTasksChanged()
|
||||
// By not invoking the callback passed to getTasks() we here emulate getTasks() loading.
|
||||
|
||||
recentTasksChangedListener?.onRecentTasksChanged()
|
||||
callbackCaptor.lastValue.accept(emptyList())
|
||||
|
||||
// getTasks() is called again now that the first getTasks() call finished.
|
||||
verify(mockRecentsModel, times(3)).getTasks(any(), any<Consumer<List<GroupTask>>>())
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(com.android.window.flags2.Flags.FLAG_ENABLE_TASKBAR_RECENT_TASKS_THROTTLE_BUGFIX)
|
||||
fun recentTasksChanged_duringGetTasksLoading_flagDisabled_callGetTasks() {
|
||||
// getTasks() should have been called once from init().
|
||||
verify(mockRecentsModel, times(1)).getTasks(any(), any<Consumer<List<GroupTask>>>())
|
||||
// Override the mock answer for getTasks() so it doesn't call the callback immediately.
|
||||
doAnswer { taskListChangeId }
|
||||
.whenever(mockRecentsModel)
|
||||
.getTasks(any(), any<Consumer<List<GroupTask>>>())
|
||||
recentTasksChangedListener?.onRecentTasksChanged()
|
||||
// By not invoking the callback passed to getTasks() we here emulate getTasks() loading.
|
||||
|
||||
recentTasksChangedListener?.onRecentTasksChanged()
|
||||
|
||||
// getTasks() is called once per onRecentTasksChanged() invocation (and once at init)
|
||||
verify(mockRecentsModel, times(3)).getTasks(any(), any<Consumer<List<GroupTask>>>())
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(com.android.window.flags2.Flags.FLAG_ENABLE_TASKBAR_RECENT_TASKS_THROTTLE_BUGFIX)
|
||||
fun recentTasksChanged_duringGetTasksLoading_flagDisabled_getTasksNotCalledWhenLoadingDone() {
|
||||
val callbackCaptor = argumentCaptor<Consumer<List<GroupTask>>>()
|
||||
// getTasks() should have been called once from init().
|
||||
verify(mockRecentsModel, times(1)).getTasks(any(), callbackCaptor.capture())
|
||||
// Override the mock answer for getTasks() so it doesn't call the callback immediately.
|
||||
doAnswer { taskListChangeId }
|
||||
.whenever(mockRecentsModel)
|
||||
.getTasks(any(), any<Consumer<List<GroupTask>>>())
|
||||
recentTasksChangedListener?.onRecentTasksChanged()
|
||||
recentTasksChangedListener?.onRecentTasksChanged()
|
||||
verify(mockRecentsModel, times(3)).getTasks(any(), any<Consumer<List<GroupTask>>>())
|
||||
|
||||
callbackCaptor.lastValue.accept(emptyList())
|
||||
|
||||
// getTasks() is called once per onRecentTasksChanged() invocation (and once at init)
|
||||
verify(mockRecentsModel, times(3)).getTasks(any(), any<Consumer<List<GroupTask>>>())
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -190,7 +281,11 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() {
|
||||
@Test
|
||||
fun getDesktopItemState_matchingVisibleTask_returnsVisible() {
|
||||
setInDesktopMode(true)
|
||||
val visibleTask = createTask(id = 1, "visiblePackage", isVisible = true)
|
||||
val visibleTask =
|
||||
PerDisplayRunningApps(
|
||||
listOf(createTask(id = 1, "visiblePackage", isVisible = true)),
|
||||
DEFAULT_DISPLAY,
|
||||
)
|
||||
updateRecentTasks(runningTasks = listOf(visibleTask), recentTaskPackages = emptyList())
|
||||
|
||||
val taskState = recentAppsController.getDesktopItemState(createItemInfo("visiblePackage"))
|
||||
@@ -198,10 +293,37 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() {
|
||||
assertThat(taskState).isEqualTo(TaskState(RunningAppState.RUNNING, taskId = 1))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getDesktopItemState_matchingVisibleTaskOnSecondaryDisplay_returnsVisible() {
|
||||
setInDesktopMode(true)
|
||||
val visibleTask1 =
|
||||
PerDisplayRunningApps(
|
||||
listOf(createTask(id = 1, "visiblePackage1", isVisible = false)),
|
||||
DEFAULT_DISPLAY,
|
||||
)
|
||||
val visibleTask2 =
|
||||
PerDisplayRunningApps(
|
||||
listOf(createTask(id = 2, "visiblePackage2", isVisible = true)),
|
||||
DEFAULT_DISPLAY + 1,
|
||||
)
|
||||
updateRecentTasks(
|
||||
runningTasks = listOf(visibleTask1, visibleTask2),
|
||||
recentTaskPackages = emptyList(),
|
||||
)
|
||||
|
||||
val taskState = recentAppsController.getDesktopItemState(createItemInfo("visiblePackage2"))
|
||||
|
||||
assertThat(taskState).isEqualTo(TaskState(RunningAppState.RUNNING, taskId = 2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getDesktopItemState_matchingMinimizedTask_returnsMinimized() {
|
||||
setInDesktopMode(true)
|
||||
val minimizedTask = createTask(id = 1, "minimizedPackage", isVisible = false)
|
||||
val minimizedTask =
|
||||
PerDisplayRunningApps(
|
||||
listOf(createTask(id = 1, "minimizedPackage", isVisible = false)),
|
||||
DEFAULT_DISPLAY,
|
||||
)
|
||||
updateRecentTasks(runningTasks = listOf(minimizedTask), recentTaskPackages = emptyList())
|
||||
|
||||
val taskState = recentAppsController.getDesktopItemState(createItemInfo("minimizedPackage"))
|
||||
@@ -209,14 +331,42 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() {
|
||||
assertThat(taskState).isEqualTo(TaskState(RunningAppState.MINIMIZED, taskId = 1))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getDesktopItemState_matchingMinimizedTaskOnSecondaryDisplay_returnsVisible() {
|
||||
setInDesktopMode(true)
|
||||
val visibleTask1 =
|
||||
PerDisplayRunningApps(
|
||||
listOf(createTask(id = 1, "visiblePackage1", isVisible = false)),
|
||||
DEFAULT_DISPLAY,
|
||||
)
|
||||
val visibleTask2 =
|
||||
PerDisplayRunningApps(
|
||||
listOf(createTask(id = 2, "visiblePackage2", isVisible = false)),
|
||||
DEFAULT_DISPLAY + 1,
|
||||
)
|
||||
updateRecentTasks(
|
||||
runningTasks = listOf(visibleTask1, visibleTask2),
|
||||
recentTaskPackages = emptyList(),
|
||||
)
|
||||
|
||||
val taskState = recentAppsController.getDesktopItemState(createItemInfo("visiblePackage2"))
|
||||
|
||||
assertThat(taskState).isEqualTo(TaskState(RunningAppState.MINIMIZED, taskId = 2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getDesktopItemState_matchingMinimizedAndRunningTask_returnsVisible() {
|
||||
setInDesktopMode(true)
|
||||
updateRecentTasks(
|
||||
runningTasks =
|
||||
listOf(
|
||||
createTask(id = 1, "package", isVisible = false),
|
||||
createTask(id = 2, "package", isVisible = true),
|
||||
PerDisplayRunningApps(
|
||||
listOf(
|
||||
createTask(id = 1, "package", isVisible = false),
|
||||
createTask(id = 2, "package", isVisible = true),
|
||||
),
|
||||
DEFAULT_DISPLAY,
|
||||
)
|
||||
),
|
||||
recentTaskPackages = emptyList(),
|
||||
)
|
||||
@@ -232,8 +382,13 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() {
|
||||
updateRecentTasks(
|
||||
runningTasks =
|
||||
listOf(
|
||||
createTask(id = 1, "package", isVisible = false, USER_HANDLE_1),
|
||||
createTask(id = 2, "package", isVisible = true, USER_HANDLE_1),
|
||||
PerDisplayRunningApps(
|
||||
listOf(
|
||||
createTask(id = 1, "package", isVisible = false, USER_HANDLE_1),
|
||||
createTask(id = 2, "package", isVisible = true, USER_HANDLE_1),
|
||||
),
|
||||
DEFAULT_DISPLAY,
|
||||
)
|
||||
),
|
||||
recentTaskPackages = emptyList(),
|
||||
)
|
||||
@@ -258,20 +413,50 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() {
|
||||
setInDesktopMode(true)
|
||||
val task1 = createTask(id = 1, packageName = RUNNING_APP_PACKAGE_1, isVisible = false)
|
||||
val task2 = createTask(id = 2, packageName = RUNNING_APP_PACKAGE_1, isVisible = true)
|
||||
updateRecentTasks(runningTasks = listOf(task1, task2), recentTaskPackages = emptyList())
|
||||
updateRecentTasks(
|
||||
runningTasks = listOf(PerDisplayRunningApps(listOf(task1, task2), DEFAULT_DISPLAY)),
|
||||
recentTaskPackages = emptyList(),
|
||||
)
|
||||
|
||||
assertThat(recentAppsController.getRunningAppState(taskId = 1))
|
||||
.isEqualTo(RunningAppState.MINIMIZED)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getRunningAppState_taskVisible_returnsRunning() {
|
||||
fun getRunningAppState_taskNotVisible_returnsMinimizedForSecondaryDisplay() {
|
||||
setInDesktopMode(true)
|
||||
val task1 = createTask(id = 1, packageName = RUNNING_APP_PACKAGE_1, isVisible = false)
|
||||
val task2 = createTask(id = 2, packageName = RUNNING_APP_PACKAGE_1, isVisible = true)
|
||||
updateRecentTasks(runningTasks = listOf(task1, task2), recentTaskPackages = emptyList())
|
||||
val task3 = createTask(id = 3, packageName = RUNNING_APP_PACKAGE_3, isVisible = false)
|
||||
updateRecentTasks(
|
||||
runningTasks =
|
||||
listOf(
|
||||
PerDisplayRunningApps(listOf(task1, task2), DEFAULT_DISPLAY),
|
||||
PerDisplayRunningApps(listOf(task3), DEFAULT_DISPLAY + 1),
|
||||
),
|
||||
recentTaskPackages = emptyList(),
|
||||
)
|
||||
|
||||
assertThat(recentAppsController.getRunningAppState(taskId = 2))
|
||||
assertThat(recentAppsController.getRunningAppState(taskId = 3))
|
||||
.isEqualTo(RunningAppState.MINIMIZED)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getRunningAppState_taskVisible_returnsRunningForSecondaryDisplay() {
|
||||
setInDesktopMode(true)
|
||||
val task1 = createTask(id = 1, packageName = RUNNING_APP_PACKAGE_1, isVisible = false)
|
||||
val task2 = createTask(id = 2, packageName = RUNNING_APP_PACKAGE_1, isVisible = true)
|
||||
val task3 = createTask(id = 3, packageName = RUNNING_APP_PACKAGE_3, isVisible = true)
|
||||
updateRecentTasks(
|
||||
runningTasks =
|
||||
listOf(
|
||||
PerDisplayRunningApps(listOf(task1, task2), DEFAULT_DISPLAY),
|
||||
PerDisplayRunningApps(listOf(task3), DEFAULT_DISPLAY + 1),
|
||||
),
|
||||
recentTaskPackages = emptyList(),
|
||||
)
|
||||
|
||||
assertThat(recentAppsController.getRunningAppState(taskId = 3))
|
||||
.isEqualTo(RunningAppState.RUNNING)
|
||||
}
|
||||
|
||||
@@ -839,7 +1024,7 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() {
|
||||
val hotseatPackageUser = PackageUser(HOTSEAT_PACKAGE_1, USER_HANDLE_2)
|
||||
val hotseatPackageUsers = listOf(hotseatPackageUser)
|
||||
val runningTask = createTask(id = 1, HOTSEAT_PACKAGE_1, localUserHandle = USER_HANDLE_1)
|
||||
val runningTasks = listOf(runningTask)
|
||||
val runningTasks = listOf(PerDisplayRunningApps(listOf(runningTask), DEFAULT_DISPLAY))
|
||||
prepareHotseatAndRunningAndRecentAppsInternal(
|
||||
hotseatPackageUsers = hotseatPackageUsers,
|
||||
runningTasks = runningTasks,
|
||||
@@ -849,6 +1034,145 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() {
|
||||
assertThat(recentAppsController.runningTaskIds).containsExactlyElementsIn(listOf(1))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun onRecentTasksChanged_inDesktopMode_multipleDesktops() {
|
||||
setInDesktopMode(true)
|
||||
val hotseatPackageUsers = listOf(PackageUser(HOTSEAT_PACKAGE_1, USER_HANDLE_1))
|
||||
val defaultDisplayRunningTask =
|
||||
createTask(id = 1, HOTSEAT_PACKAGE_1, localUserHandle = USER_HANDLE_1)
|
||||
val secondaryDisplayRunningTask =
|
||||
createTask(id = 2, RUNNING_APP_PACKAGE_1, localUserHandle = USER_HANDLE_1)
|
||||
val runningTasks =
|
||||
listOf(
|
||||
PerDisplayRunningApps(listOf(defaultDisplayRunningTask), DEFAULT_DISPLAY),
|
||||
PerDisplayRunningApps(listOf(secondaryDisplayRunningTask), DEFAULT_DISPLAY + 1),
|
||||
)
|
||||
prepareHotseatAndRunningAndRecentAppsInternal(
|
||||
hotseatPackageUsers = hotseatPackageUsers,
|
||||
runningTasks = runningTasks,
|
||||
recentTaskPackages = emptyList(),
|
||||
)
|
||||
assertThat(recentShownTasks).containsExactly(secondaryDisplayRunningTask)
|
||||
assertThat(recentAppsController.runningTaskIds).containsExactlyElementsIn(listOf(1, 2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun onRecentTasksChanged_inDesktopMode_multipleDesktops_appsNotInHotseat() {
|
||||
setInDesktopMode(true)
|
||||
val hotseatPackageUsers = listOf(PackageUser(HOTSEAT_PACKAGE_1, USER_HANDLE_1))
|
||||
val defaultDisplayRunningTask =
|
||||
createTask(id = 1, RUNNING_APP_PACKAGE_1, localUserHandle = USER_HANDLE_1)
|
||||
val secondaryDisplayRunningTask =
|
||||
createTask(id = 2, RUNNING_APP_PACKAGE_2, localUserHandle = USER_HANDLE_1)
|
||||
val runningTasks =
|
||||
listOf(
|
||||
PerDisplayRunningApps(listOf(defaultDisplayRunningTask), DEFAULT_DISPLAY),
|
||||
PerDisplayRunningApps(listOf(secondaryDisplayRunningTask), DEFAULT_DISPLAY + 1),
|
||||
)
|
||||
prepareHotseatAndRunningAndRecentAppsInternal(
|
||||
hotseatPackageUsers = hotseatPackageUsers,
|
||||
runningTasks = runningTasks,
|
||||
recentTaskPackages = emptyList(),
|
||||
)
|
||||
assertThat(recentShownTasks)
|
||||
.containsExactly(defaultDisplayRunningTask, secondaryDisplayRunningTask)
|
||||
assertThat(recentAppsController.runningTaskIds).containsExactlyElementsIn(listOf(1, 2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun onRecentTasksChanged_inDesktopMode_multipleDesktops_multipleAppInstances() {
|
||||
setInDesktopMode(true)
|
||||
val hotseatPackageUsers = listOf(PackageUser(HOTSEAT_PACKAGE_1, USER_HANDLE_1))
|
||||
val defaultDisplayRunningTask1 =
|
||||
createTask(id = 1, HOTSEAT_PACKAGE_1, localUserHandle = USER_HANDLE_1)
|
||||
val defaultDisplayRunningTask2 =
|
||||
createTask(id = 2, RUNNING_APP_PACKAGE_1, localUserHandle = USER_HANDLE_1)
|
||||
|
||||
val secondaryDisplayRunningTask1 =
|
||||
createTask(id = 3, RUNNING_APP_PACKAGE_1, localUserHandle = USER_HANDLE_1)
|
||||
val secondaryDisplayRunningTask2 =
|
||||
createTask(id = 4, HOTSEAT_PACKAGE_1, localUserHandle = USER_HANDLE_1)
|
||||
|
||||
val runningTasks =
|
||||
listOf(
|
||||
PerDisplayRunningApps(
|
||||
listOf(defaultDisplayRunningTask1, defaultDisplayRunningTask2),
|
||||
DEFAULT_DISPLAY,
|
||||
),
|
||||
PerDisplayRunningApps(
|
||||
listOf(secondaryDisplayRunningTask1, secondaryDisplayRunningTask2),
|
||||
DEFAULT_DISPLAY + 1,
|
||||
),
|
||||
)
|
||||
prepareHotseatAndRunningAndRecentAppsInternal(
|
||||
hotseatPackageUsers = hotseatPackageUsers,
|
||||
runningTasks = runningTasks,
|
||||
recentTaskPackages = emptyList(),
|
||||
)
|
||||
|
||||
assertThat(recentShownTasks).hasSize(1)
|
||||
assertThat(recentShownTasks)
|
||||
.containsAnyOf(defaultDisplayRunningTask2, secondaryDisplayRunningTask1)
|
||||
|
||||
assertThat(recentAppsController.runningTaskIds)
|
||||
.containsExactlyElementsIn(listOf(1, 2, 3, 4))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun hasSingleTask_noTargetPackage_returnsFalse() {
|
||||
prepareHotseatAndRunningAndRecentApps(
|
||||
hotseatPackages = emptyList(),
|
||||
runningTasks = emptyList(),
|
||||
recentTaskPackages = listOf(RECENT_PACKAGE_1),
|
||||
)
|
||||
assertThat(recentAppsController.hasSingleTask(ItemInfo())).isFalse()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun hasSingleTask_noRecentTasks_returnsFalse() {
|
||||
prepareHotseatAndRunningAndRecentApps(
|
||||
hotseatPackages = emptyList(),
|
||||
runningTasks = emptyList(),
|
||||
recentTaskPackages = emptyList(),
|
||||
)
|
||||
val itemInfo = createItemInfo(RECENT_PACKAGE_1)
|
||||
assertThat(recentAppsController.hasSingleTask(itemInfo)).isFalse()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun hasSingleTask_noMatchingSingleTask_returnsFalse() {
|
||||
prepareHotseatAndRunningAndRecentApps(
|
||||
hotseatPackages = emptyList(),
|
||||
runningTasks = emptyList(),
|
||||
recentTaskPackages = listOf(RECENT_PACKAGE_1),
|
||||
)
|
||||
val itemInfo = createItemInfo(RECENT_PACKAGE_2)
|
||||
assertThat(recentAppsController.hasSingleTask(itemInfo)).isFalse()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun hasSingleTask_matchingSingleTask_returnsTrue() {
|
||||
prepareHotseatAndRunningAndRecentApps(
|
||||
hotseatPackages = emptyList(),
|
||||
runningTasks = emptyList(),
|
||||
recentTaskPackages = listOf(RECENT_PACKAGE_1, RECENT_PACKAGE_2),
|
||||
)
|
||||
val itemInfo = createItemInfo(RECENT_PACKAGE_1)
|
||||
assertThat(recentAppsController.hasSingleTask(itemInfo)).isTrue()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun hasSingleTask_matchingSingleTaskDifferentUser_returnsFalse() {
|
||||
prepareHotseatAndRunningAndRecentApps(
|
||||
hotseatPackages = emptyList(),
|
||||
runningTasks = emptyList(),
|
||||
recentTaskPackages = listOf(RECENT_PACKAGE_1),
|
||||
)
|
||||
// RECENT_PACKAGE_1 is created with myUserHandle in createRecentTasksFromPackageNames
|
||||
val itemInfo = createItemInfo(RECENT_PACKAGE_1, USER_HANDLE_1)
|
||||
assertThat(recentAppsController.hasSingleTask(itemInfo)).isFalse()
|
||||
}
|
||||
|
||||
private fun prepareHotseatAndRunningAndRecentApps(
|
||||
hotseatPackages: List<String>,
|
||||
runningTasks: List<Task>,
|
||||
@@ -857,14 +1181,14 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() {
|
||||
val hotseatPackageUsers = hotseatPackages.map { PackageUser(it, myUserHandle) }
|
||||
return prepareHotseatAndRunningAndRecentAppsInternal(
|
||||
hotseatPackageUsers,
|
||||
runningTasks,
|
||||
listOf(PerDisplayRunningApps(runningTasks, DEFAULT_DISPLAY)),
|
||||
recentTaskPackages,
|
||||
)
|
||||
}
|
||||
|
||||
private fun prepareHotseatAndRunningAndRecentAppsInternal(
|
||||
hotseatPackageUsers: List<PackageUser>,
|
||||
runningTasks: List<Task>,
|
||||
runningTasks: List<PerDisplayRunningApps>,
|
||||
recentTaskPackages: List<String>,
|
||||
): Array<ItemInfo?> {
|
||||
val hotseatItems = createHotseatItemsFromPackageUsers(hotseatPackageUsers)
|
||||
@@ -873,22 +1197,25 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() {
|
||||
return recentAppsController.shownHotseatItems.toTypedArray()
|
||||
}
|
||||
|
||||
private fun updateRecentTasks(runningTasks: List<Task>, recentTaskPackages: List<String>) {
|
||||
private fun updateRecentTasks(
|
||||
runningTasks: List<PerDisplayRunningApps>,
|
||||
recentTaskPackages: List<String>,
|
||||
) {
|
||||
val recentTasks = createRecentTasksFromPackageNames(recentTaskPackages)
|
||||
val allTasks =
|
||||
ArrayList<GroupTask>().apply {
|
||||
if (!runningTasks.isEmpty()) {
|
||||
add(DesktopTask(deskId = 0, DEFAULT_DISPLAY, ArrayList(runningTasks)))
|
||||
runningTasks.forEach {
|
||||
add(DesktopTask(deskId = 0, it.displayId, ArrayList(it.tasks)))
|
||||
}
|
||||
addAll(recentTasks)
|
||||
}
|
||||
doAnswer {
|
||||
val callback: Consumer<ArrayList<GroupTask>> = it.getArgument(0)
|
||||
val callback: Consumer<ArrayList<GroupTask>> = it.getArgument(1)
|
||||
callback.accept(allTasks)
|
||||
taskListChangeId
|
||||
}
|
||||
.whenever(mockRecentsModel)
|
||||
.getTasks(any<Consumer<List<GroupTask>>>(), any())
|
||||
.getTasks(any(), any<Consumer<List<GroupTask>>>())
|
||||
recentTasksChangedListener?.onRecentTasksChanged()
|
||||
}
|
||||
|
||||
@@ -922,11 +1249,11 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() {
|
||||
SplitTask(
|
||||
createTask(100, splitPackages[0]),
|
||||
createTask(101, splitPackages[1]),
|
||||
SplitConfigurationOptions.SplitBounds(
|
||||
SplitBounds(
|
||||
/* leftTopBounds = */ Rect(),
|
||||
/* rightBottomBounds = */ Rect(),
|
||||
/* leftTopTaskId = */ -1,
|
||||
/* rightBottomTaskId = */ -1,
|
||||
/* leftTopTaskId = */ 1,
|
||||
/* rightBottomTaskId = */ 2,
|
||||
/* snapPosition = */ SplitScreenConstants.SNAP_TO_2_50_50,
|
||||
),
|
||||
)
|
||||
@@ -991,4 +1318,6 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() {
|
||||
}
|
||||
|
||||
data class PackageUser(val packageName: String, val userHandle: UserHandle)
|
||||
|
||||
data class PerDisplayRunningApps(val tasks: List<Task>, val displayId: Int)
|
||||
}
|
||||
+85
-7
@@ -17,12 +17,17 @@
|
||||
package com.android.launcher3.taskbar
|
||||
|
||||
import android.animation.AnimatorTestRule
|
||||
import android.platform.test.annotations.DisableFlags
|
||||
import android.platform.test.annotations.EnableFlags
|
||||
import android.platform.test.flag.junit.SetFlagsRule
|
||||
import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation
|
||||
import com.android.launcher3.Flags
|
||||
import com.android.launcher3.LauncherPrefs
|
||||
import com.android.launcher3.LauncherPrefs.Companion.TASKBAR_PINNING
|
||||
import com.android.launcher3.LauncherPrefs.Companion.TASKBAR_PINNING_IN_DESKTOP_MODE
|
||||
import com.android.launcher3.QuickstepTransitionManager.PINNED_TASKBAR_TRANSITION_DURATION
|
||||
import com.android.launcher3.R
|
||||
import com.android.launcher3.statehandlers.DesktopVisibilityController
|
||||
import com.android.launcher3.taskbar.StashedHandleViewController.ALPHA_INDEX_STASHED
|
||||
import com.android.launcher3.taskbar.TaskbarAutohideSuspendController.FLAG_AUTOHIDE_SUSPEND_EDU_OPEN
|
||||
import com.android.launcher3.taskbar.TaskbarControllerTestUtil.asProperty
|
||||
@@ -50,6 +55,7 @@ import com.android.launcher3.taskbar.rules.TaskbarUnitTestRule
|
||||
import com.android.launcher3.taskbar.rules.TaskbarUnitTestRule.InjectController
|
||||
import com.android.launcher3.taskbar.rules.TaskbarUnitTestRule.UserSetupMode
|
||||
import com.android.launcher3.taskbar.rules.TaskbarWindowSandboxContext
|
||||
import com.android.launcher3.taskbar.rules.displayControllerSpy
|
||||
import com.android.launcher3.util.LauncherMultivalentJUnit
|
||||
import com.android.launcher3.util.LauncherMultivalentJUnit.EmulatedDevices
|
||||
import com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_BUBBLES_EXPANDED
|
||||
@@ -61,6 +67,9 @@ import org.junit.After
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.kotlin.doReturn
|
||||
import org.mockito.kotlin.spy
|
||||
import org.mockito.kotlin.whenever
|
||||
|
||||
@RunWith(LauncherMultivalentJUnit::class)
|
||||
@EnableFlags(FLAG_ENABLE_BUBBLE_BAR)
|
||||
@@ -80,6 +89,9 @@ class TaskbarStashControllerTest {
|
||||
@InjectController lateinit var bubbleBarViewController: BubbleBarViewController
|
||||
@InjectController lateinit var bubbleStashController: BubbleStashController
|
||||
|
||||
private val desktopVisibilityController: DesktopVisibilityController
|
||||
get() = DesktopVisibilityController.INSTANCE[context]
|
||||
|
||||
private val activityContext by taskbarUnitTestRule::activityContext
|
||||
|
||||
@After fun cancelTimeoutIfExists() = stashController.cancelTimeoutIfExists()
|
||||
@@ -118,7 +130,27 @@ class TaskbarStashControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testRecreateAsTransient_timeoutStarted() {
|
||||
@DisableFlags(Flags.FLAG_ENABLE_OVERVIEW_ON_CONNECTED_DISPLAYS)
|
||||
fun testRecreateAsTransient_withoutOverviewOnConnectedDisplays_timeoutStarted() {
|
||||
context.displayControllerSpy?.setupTaskbarPinningPrefListener(context.displayId)
|
||||
|
||||
testRecreateAsTransient_timeoutStarted()
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_ENABLE_OVERVIEW_ON_CONNECTED_DISPLAYS)
|
||||
fun testRecreateAsTransient_withOverviewOnConnectedDisplay_timeoutStarted() {
|
||||
context.displayControllerSpy?.let { controller ->
|
||||
controller.setupTaskbarPinningPrefListener(context.displayId)
|
||||
controller.infoModifierForDisplay = {
|
||||
spy(it) { on { it?.isTransientTaskbar } doReturn true }
|
||||
}
|
||||
}
|
||||
|
||||
testRecreateAsTransient_timeoutStarted()
|
||||
}
|
||||
|
||||
private fun testRecreateAsTransient_timeoutStarted() {
|
||||
var isPinned by TASKBAR_PINNING.asProperty(context)
|
||||
isPinned = true
|
||||
activityContext.controllers.sharedState?.taskbarWasPinned = true
|
||||
@@ -293,7 +325,7 @@ class TaskbarStashControllerTest {
|
||||
}
|
||||
|
||||
val expectedHeight =
|
||||
activityContext.deviceProfile.run { taskbarHeight + taskbarBottomMargin }
|
||||
activityContext.deviceProfile.taskbarProfile.run { height + bottomMargin }
|
||||
assertThat(stashController.touchableHeight).isEqualTo(expectedHeight)
|
||||
}
|
||||
|
||||
@@ -301,7 +333,7 @@ class TaskbarStashControllerTest {
|
||||
@TaskbarMode(PINNED)
|
||||
fun testGetTouchableHeight_pinnedMode_taskbarHeight() {
|
||||
assertThat(stashController.touchableHeight)
|
||||
.isEqualTo(activityContext.deviceProfile.taskbarHeight)
|
||||
.isEqualTo(activityContext.deviceProfile.taskbarProfile.height)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -315,22 +347,33 @@ class TaskbarStashControllerTest {
|
||||
@TaskbarMode(THREE_BUTTONS)
|
||||
fun testGetContentHeightToReportToApps_threeButtonsMode_taskbarHeight() {
|
||||
assertThat(stashController.contentHeightToReportToApps)
|
||||
.isEqualTo(activityContext.deviceProfile.taskbarHeight)
|
||||
.isEqualTo(activityContext.deviceProfile.taskbarProfile.height)
|
||||
}
|
||||
|
||||
@Test
|
||||
@TaskbarMode(PINNED)
|
||||
fun testGetContentHeightToReportToApps_pinnedMode_taskbarHeight() {
|
||||
assertThat(stashController.contentHeightToReportToApps)
|
||||
.isEqualTo(activityContext.deviceProfile.taskbarHeight)
|
||||
.isEqualTo(activityContext.deviceProfile.taskbarProfile.height)
|
||||
}
|
||||
|
||||
@Test
|
||||
@TaskbarMode(PINNED)
|
||||
@UserSetupMode
|
||||
fun testGetContentHeightToReportToApps_pinnedInSetupMode_setupWizardInsets() {
|
||||
stashController.mNavbarHiddenOverrideForTest = false
|
||||
assertThat(stashController.contentHeightToReportToApps)
|
||||
.isEqualTo(context.resources.getDimensionPixelSize(R.dimen.taskbar_suw_insets))
|
||||
stashController.mNavbarHiddenOverrideForTest = null
|
||||
}
|
||||
|
||||
@Test
|
||||
@UserSetupMode
|
||||
fun testGetContentHeightToReportToApps_inExpressiveTheme_setupWizardInsets() {
|
||||
stashController.mNavbarHiddenOverrideForTest = true
|
||||
assertThat(stashController.contentHeightToReportToApps)
|
||||
.isEqualTo(stashController.stashedHeight)
|
||||
stashController.mNavbarHiddenOverrideForTest = null
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -365,7 +408,7 @@ class TaskbarStashControllerTest {
|
||||
@TaskbarMode(PINNED)
|
||||
fun testGetTappableHeightToReportToApps_pinnedMode_taskbarHeight() {
|
||||
assertThat(stashController.tappableHeightToReportToApps)
|
||||
.isEqualTo(activityContext.deviceProfile.taskbarHeight)
|
||||
.isEqualTo(activityContext.deviceProfile.taskbarProfile.height)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -387,6 +430,41 @@ class TaskbarStashControllerTest {
|
||||
assertThat(stashController.timeoutAlarm.alarmPending()).isTrue()
|
||||
}
|
||||
|
||||
@Test
|
||||
@TaskbarMode(PINNED)
|
||||
fun testUpdateTaskbarTimeout_unPinnedTaskbarInDesktopMode_startsTaskbarTimeout() {
|
||||
LauncherPrefs.get(context).put(TASKBAR_PINNING_IN_DESKTOP_MODE, false)
|
||||
whenever(desktopVisibilityController.isInDesktopMode(context.displayId)).thenReturn(true)
|
||||
stashController.updateTaskbarTimeout(false)
|
||||
assertThat(stashController.timeoutAlarm.alarmPending()).isTrue()
|
||||
}
|
||||
|
||||
@Test
|
||||
@TaskbarMode(PINNED)
|
||||
fun testUpdateTaskbarTimeout_pinnedTaskbarInDesktopMode_shouldNotStartsTaskbarTimeout() {
|
||||
LauncherPrefs.get(context).put(TASKBAR_PINNING_IN_DESKTOP_MODE, true)
|
||||
whenever(desktopVisibilityController.isInDesktopMode(context.displayId)).thenReturn(true)
|
||||
stashController.updateTaskbarTimeout(false)
|
||||
assertThat(stashController.timeoutAlarm.alarmPending()).isFalse()
|
||||
}
|
||||
|
||||
@Test
|
||||
@TaskbarMode(TRANSIENT)
|
||||
fun shouldAllowTaskbarToAutoStash_transientTaskbar() {
|
||||
assertThat(stashController.shouldAllowTaskbarToAutoStash()).isTrue()
|
||||
}
|
||||
|
||||
@Test
|
||||
@TaskbarMode(PINNED)
|
||||
fun toggleTaskbarStash_autoStashedDesktopModeTaskbar() {
|
||||
LauncherPrefs.get(context).put(TASKBAR_PINNING_IN_DESKTOP_MODE, false)
|
||||
whenever(desktopVisibilityController.isInDesktopMode(context.displayId)).thenReturn(true)
|
||||
|
||||
getInstrumentation().runOnMainSync { stashController.toggleTaskbarStash() }
|
||||
|
||||
assertThat(stashController.isStashed).isTrue()
|
||||
}
|
||||
|
||||
@Test
|
||||
@TaskbarMode(TRANSIENT)
|
||||
fun testUpdateAndAnimateTransientTaskbar_finishTaskbarTimeout_taskbarStashes() {
|
||||
@@ -468,7 +546,7 @@ class TaskbarStashControllerTest {
|
||||
fun testUpdateAndAnimateTransientTaskbar_bubbleBarExpandedBeforeTimeout_expandedAfterwards() {
|
||||
getInstrumentation().runOnMainSync {
|
||||
bubbleBarViewController.setHiddenForBubbles(false)
|
||||
bubbleBarViewController.isExpanded = true
|
||||
bubbleBarViewController.animateExpanded(true)
|
||||
stashController.updateAndAnimateTransientTaskbar(false)
|
||||
animatorTestRule.advanceTimeBy(stashController.stashDuration)
|
||||
}
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ import com.android.launcher3.taskbar.rules.TaskbarUnitTestRule
|
||||
import com.android.launcher3.taskbar.rules.TaskbarUnitTestRule.ForceRtl
|
||||
import com.android.launcher3.taskbar.rules.TaskbarWindowSandboxContext
|
||||
import com.android.launcher3.util.LauncherMultivalentJUnit.Companion.isRunningInRobolectric
|
||||
import com.android.window.flags.Flags.FLAG_ENABLE_TASKBAR_RECENTS_LAYOUT_TRANSITION
|
||||
import com.android.window.flags2.Flags.FLAG_ENABLE_TASKBAR_RECENTS_LAYOUT_TRANSITION
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
|
||||
+52
-27
@@ -21,8 +21,8 @@ import android.content.Intent
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.Bitmap.createBitmap
|
||||
import android.os.Process
|
||||
import com.android.launcher3.LauncherSettings.Favorites.CONTAINER_HOTSEAT
|
||||
import com.android.launcher3.icons.BitmapInfo
|
||||
import com.android.launcher3.model.data.AppInfo
|
||||
import com.android.launcher3.model.data.AppPairInfo
|
||||
import com.android.launcher3.model.data.FolderInfo
|
||||
import com.android.launcher3.model.data.ItemInfo
|
||||
@@ -50,19 +50,37 @@ object TaskbarViewTestUtil {
|
||||
}
|
||||
|
||||
/** Creates an array of fake hotseat items. */
|
||||
fun createHotseatItems(size: Int): Array<ItemInfo> {
|
||||
fun createHotseatItems(size: Int): Array<WorkspaceItemInfo> {
|
||||
return Array(size) { createHotseatWorkspaceItem(it) }
|
||||
}
|
||||
|
||||
fun createHotseatWorkspaceItem(id: Int = 0): WorkspaceItemInfo {
|
||||
return WorkspaceItemInfo(
|
||||
AppInfo(TEST_COMPONENT, "Test App $id", Process.myUserHandle(), Intent())
|
||||
)
|
||||
.apply {
|
||||
this.id = id
|
||||
// Create a placeholder icon so that the test doesn't try to load a high-res icon.
|
||||
this.bitmap = BitmapInfo.fromBitmap(createBitmap(1, 1, Bitmap.Config.ALPHA_8))
|
||||
}
|
||||
return createTestWorkspaceItem(
|
||||
id,
|
||||
"Test App $id",
|
||||
testIntent(id),
|
||||
Process.myUserHandle(),
|
||||
CONTAINER_HOTSEAT,
|
||||
)
|
||||
}
|
||||
|
||||
// Helper to create a test WorkspaceItemInfo
|
||||
fun createTestWorkspaceItem(
|
||||
id: Int,
|
||||
title: String,
|
||||
intent: Intent,
|
||||
user: android.os.UserHandle,
|
||||
container: Int,
|
||||
): WorkspaceItemInfo {
|
||||
val item = WorkspaceItemInfo()
|
||||
item.id = id
|
||||
item.title = title
|
||||
item.intent = intent
|
||||
item.user = user
|
||||
item.container = container
|
||||
// Create a placeholder icon so that the test doesn't try to load a high-res icon.
|
||||
item.bitmap = BitmapInfo.fromBitmap(createBitmap(1, 1, Bitmap.Config.ALPHA_8))
|
||||
return item
|
||||
}
|
||||
|
||||
fun createHotseatAppPairsItem(): AppPairInfo {
|
||||
@@ -83,21 +101,23 @@ object TaskbarViewTestUtil {
|
||||
|
||||
/** Creates a list of fake recent tasks. */
|
||||
fun createRecents(size: Int): List<GroupTask> {
|
||||
return List(size) {
|
||||
SingleTask(
|
||||
Task().apply {
|
||||
key =
|
||||
TaskKey(
|
||||
it,
|
||||
5,
|
||||
TEST_INTENT,
|
||||
TEST_COMPONENT,
|
||||
Process.myUserHandle().identifier,
|
||||
System.currentTimeMillis(),
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
return List(size) { createRecentTask(it) }
|
||||
}
|
||||
|
||||
fun createRecentTask(id: Int = 0): GroupTask {
|
||||
return SingleTask(
|
||||
Task().apply {
|
||||
key =
|
||||
TaskKey(
|
||||
id,
|
||||
5,
|
||||
testIntent(id),
|
||||
testComponent(id),
|
||||
Process.myUserHandle().identifier,
|
||||
System.currentTimeMillis(),
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,5 +167,10 @@ enum class TaskbarIconType {
|
||||
}
|
||||
|
||||
private const val TEST_PACKAGE = "com.android.launcher3.taskbar"
|
||||
private val TEST_COMPONENT = ComponentName(TEST_PACKAGE, "Activity")
|
||||
private val TEST_INTENT = Intent().apply { `package` = TEST_PACKAGE }
|
||||
private val testComponent = { i: Int -> ComponentName(TEST_PACKAGE, "Activity $i") }
|
||||
private val testIntent = { i: Int ->
|
||||
Intent().apply {
|
||||
`package` = TEST_PACKAGE
|
||||
component = testComponent(i)
|
||||
}
|
||||
}
|
||||
+14
-3
@@ -19,7 +19,6 @@ package com.android.launcher3.taskbar
|
||||
import android.platform.test.annotations.EnableFlags
|
||||
import android.platform.test.flag.junit.SetFlagsRule
|
||||
import android.view.View
|
||||
import com.android.launcher3.Flags.FLAG_TASKBAR_OVERFLOW
|
||||
import com.android.launcher3.R
|
||||
import com.android.launcher3.statehandlers.DesktopVisibilityController
|
||||
import com.android.launcher3.taskbar.TaskbarControllerTestUtil.runOnMainSync
|
||||
@@ -36,7 +35,8 @@ import com.android.launcher3.taskbar.rules.TaskbarUnitTestRule.ForceRtl
|
||||
import com.android.launcher3.taskbar.rules.TaskbarWindowSandboxContext
|
||||
import com.android.launcher3.util.LauncherMultivalentJUnit
|
||||
import com.android.launcher3.util.LauncherMultivalentJUnit.EmulatedDevices
|
||||
import com.android.window.flags.Flags.FLAG_ENABLE_TASKBAR_RECENTS_LAYOUT_TRANSITION
|
||||
import com.android.window.flags2.Flags.FLAG_ENABLE_TASKBAR_OVERFLOW
|
||||
import com.android.window.flags2.Flags.FLAG_ENABLE_TASKBAR_RECENTS_LAYOUT_TRANSITION
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
@@ -46,7 +46,7 @@ import org.mockito.kotlin.whenever
|
||||
|
||||
@RunWith(LauncherMultivalentJUnit::class)
|
||||
@EmulatedDevices(["pixelFoldable2023", "pixelTablet2023"])
|
||||
@EnableFlags(FLAG_ENABLE_TASKBAR_RECENTS_LAYOUT_TRANSITION, FLAG_TASKBAR_OVERFLOW)
|
||||
@EnableFlags(FLAG_ENABLE_TASKBAR_OVERFLOW, FLAG_ENABLE_TASKBAR_RECENTS_LAYOUT_TRANSITION)
|
||||
class TaskbarViewWithLayoutTransitionTest {
|
||||
|
||||
@get:Rule(order = 0) val setFlagsRule = SetFlagsRule()
|
||||
@@ -243,6 +243,17 @@ class TaskbarViewWithLayoutTransitionTest {
|
||||
assertThat(taskbarView).hasIconTypes(ALL_APPS, HOTSEAT)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testUpdateItems_desktopMode_hotseatItem_noDividerAfterDesktopModeChange() {
|
||||
whenever(desktopVisibilityController.isInDesktopMode(context.displayId)).thenReturn(false)
|
||||
runOnMainSync { taskbarView.updateItems(createHotseatItems(1), emptyList()) }
|
||||
|
||||
whenever(desktopVisibilityController.isInDesktopMode(context.displayId)).thenReturn(true)
|
||||
runOnMainSync { taskbarView.updateItems(createHotseatItems(2), emptyList()) }
|
||||
|
||||
assertThat(taskbarView).hasIconTypes(ALL_APPS, HOTSEAT, HOTSEAT)
|
||||
}
|
||||
|
||||
@Test
|
||||
@ForceRtl
|
||||
fun testUpdateItems_rtlAndDesktopMode_hotseatItem_noDivider() {
|
||||
|
||||
+2
@@ -50,6 +50,7 @@ class BubbleBarInputConsumerTest {
|
||||
@Mock private lateinit var bubbleBarPinController: BubbleBarPinController
|
||||
@Mock private lateinit var bubblePinController: BubblePinController
|
||||
@Mock private lateinit var bubbleBarSwipeController: BubbleBarSwipeController
|
||||
@Mock private lateinit var dragToBubbleController: DragToBubbleController
|
||||
@Mock private lateinit var bubbleCreator: BubbleCreator
|
||||
|
||||
@Mock private lateinit var motionEvent: MotionEvent
|
||||
@@ -69,6 +70,7 @@ class BubbleBarInputConsumerTest {
|
||||
bubbleBarPinController,
|
||||
bubblePinController,
|
||||
Optional.of(bubbleBarSwipeController),
|
||||
dragToBubbleController,
|
||||
bubbleCreator,
|
||||
)
|
||||
}
|
||||
|
||||
+2
@@ -69,6 +69,7 @@ class BubbleBarSwipeControllerTest {
|
||||
@Mock private lateinit var bubbleDismissController: BubbleDismissController
|
||||
@Mock private lateinit var bubbleBarPinController: BubbleBarPinController
|
||||
@Mock private lateinit var bubblePinController: BubblePinController
|
||||
@Mock private lateinit var dragToBubbleController: DragToBubbleController
|
||||
@Mock private lateinit var bubbleCreator: BubbleCreator
|
||||
|
||||
@Before
|
||||
@@ -94,6 +95,7 @@ class BubbleBarSwipeControllerTest {
|
||||
bubbleBarPinController,
|
||||
bubblePinController,
|
||||
Optional.of(bubbleBarSwipeController),
|
||||
dragToBubbleController,
|
||||
bubbleCreator,
|
||||
)
|
||||
|
||||
|
||||
+24
-3
@@ -29,6 +29,7 @@ import com.android.launcher3.taskbar.bubbles.BubbleBarView
|
||||
import com.android.launcher3.taskbar.bubbles.BubbleBarViewController
|
||||
import com.android.launcher3.taskbar.bubbles.stashing.BubbleStashController.BubbleLauncherState
|
||||
import com.android.launcher3.util.MultiValueAlpha
|
||||
import com.android.wm.shell.shared.bubbles.BubbleBarLocation
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
@@ -353,7 +354,7 @@ class PersistentBubbleStashControllerTest {
|
||||
bubbleBarGesture = true,
|
||||
)
|
||||
|
||||
verify(bubbleBarViewController).setExpanded(true, true)
|
||||
verify(bubbleBarViewController).animateExpanded(true, true)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -366,7 +367,7 @@ class PersistentBubbleStashControllerTest {
|
||||
bubbleBarGesture = false,
|
||||
)
|
||||
|
||||
verify(bubbleBarViewController).setExpanded(true, false)
|
||||
verify(bubbleBarViewController).animateExpanded(true, false)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -379,7 +380,7 @@ class PersistentBubbleStashControllerTest {
|
||||
bubbleBarGesture = true,
|
||||
)
|
||||
|
||||
verify(bubbleBarViewController, never()).setExpanded(any(), any())
|
||||
verify(bubbleBarViewController, never()).animateExpanded(any(), any())
|
||||
}
|
||||
|
||||
private fun advanceTimeBy(advanceMs: Long) {
|
||||
@@ -391,6 +392,26 @@ class PersistentBubbleStashControllerTest {
|
||||
getInstrumentation().runOnMainSync {
|
||||
bubbleBarView = BubbleBarView(context)
|
||||
bubbleBarView.layoutParams = FrameLayout.LayoutParams(0, 0)
|
||||
bubbleBarView.setController(
|
||||
object : BubbleBarView.Controller {
|
||||
override fun getBubbleBarTranslationY(): Float = 0f
|
||||
|
||||
override fun onBubbleBarTouched() {}
|
||||
|
||||
override fun expandBubbleBar() {}
|
||||
|
||||
override fun dismissBubbleBar() {}
|
||||
|
||||
override fun updateBubbleBarLocation(
|
||||
location: BubbleBarLocation?,
|
||||
source: Int,
|
||||
) {}
|
||||
|
||||
override fun setIsDragging(dragging: Boolean) {}
|
||||
|
||||
override fun onBubbleBarExpandedStateChanged(expanded: Boolean) {}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+25
-4
@@ -38,6 +38,7 @@ import com.android.launcher3.taskbar.bubbles.stashing.BubbleStashController.Bubb
|
||||
import com.android.launcher3.util.MultiValueAlpha
|
||||
import com.android.wm.shell.shared.animation.PhysicsAnimator
|
||||
import com.android.wm.shell.shared.animation.PhysicsAnimatorTestUtils
|
||||
import com.android.wm.shell.shared.bubbles.BubbleBarLocation
|
||||
import com.google.common.collect.Range
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import org.junit.Before
|
||||
@@ -375,7 +376,7 @@ class TransientBubbleStashControllerTest {
|
||||
)
|
||||
}
|
||||
|
||||
verify(bubbleBarViewController).setExpanded(true, true)
|
||||
verify(bubbleBarViewController).animateExpanded(true, true)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -392,7 +393,7 @@ class TransientBubbleStashControllerTest {
|
||||
)
|
||||
}
|
||||
|
||||
verify(bubbleBarViewController).setExpanded(true, false)
|
||||
verify(bubbleBarViewController).animateExpanded(true, false)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -409,7 +410,7 @@ class TransientBubbleStashControllerTest {
|
||||
)
|
||||
}
|
||||
|
||||
verify(bubbleBarViewController, never()).setExpanded(any(), any())
|
||||
verify(bubbleBarViewController, never()).animateExpanded(any(), any())
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -556,8 +557,28 @@ class TransientBubbleStashControllerTest {
|
||||
bubbleBarView = BubbleBarView(context)
|
||||
bubbleBarView.layoutParams =
|
||||
FrameLayout.LayoutParams(BUBBLE_BAR_WIDTH, BUBBLE_BAR_HEIGHT)
|
||||
bubbleBarView.setController(
|
||||
object : BubbleBarView.Controller {
|
||||
override fun getBubbleBarTranslationY(): Float = 0f
|
||||
|
||||
override fun onBubbleBarTouched() {}
|
||||
|
||||
override fun expandBubbleBar() {}
|
||||
|
||||
override fun dismissBubbleBar() {}
|
||||
|
||||
override fun updateBubbleBarLocation(
|
||||
location: BubbleBarLocation?,
|
||||
source: Int,
|
||||
) {}
|
||||
|
||||
override fun setIsDragging(dragging: Boolean) {}
|
||||
|
||||
override fun onBubbleBarExpandedStateChanged(expanded: Boolean) {}
|
||||
}
|
||||
)
|
||||
bubbleView = BubbleView(context)
|
||||
bubbleBarView.addBubble(bubbleView)
|
||||
bubbleBarView.addBubble(bubbleView, false)
|
||||
bubbleBarView.layout(0, 0, BUBBLE_BAR_WIDTH, BUBBLE_BAR_HEIGHT)
|
||||
}
|
||||
}
|
||||
|
||||
+13
-13
@@ -14,6 +14,7 @@ import androidx.test.runner.AndroidJUnit4
|
||||
import com.android.launcher3.DeviceProfile
|
||||
import com.android.launcher3.R
|
||||
import com.android.launcher3.config.FeatureFlags.ENABLE_TASKBAR_NAVBAR_UNIFICATION
|
||||
import com.android.launcher3.deviceprofile.DeviceProperties
|
||||
import com.android.launcher3.taskbar.navbutton.LayoutResourceHelper.ID_END_CONTEXTUAL_BUTTONS
|
||||
import com.android.launcher3.taskbar.navbutton.LayoutResourceHelper.ID_END_NAV_BUTTONS
|
||||
import com.android.launcher3.taskbar.navbutton.LayoutResourceHelper.ID_START_CONTEXTUAL_BUTTONS
|
||||
@@ -50,6 +51,8 @@ class NavButtonLayoutFactoryTest {
|
||||
whenever(mockNavLayout.findViewById<View>(R.id.back)).thenReturn(mockBackButton)
|
||||
whenever(mockNavLayout.findViewById<View>(R.id.home)).thenReturn(mockHomeButton)
|
||||
whenever(mockNavLayout.findViewById<View>(R.id.recent_apps)).thenReturn(mockRecentsButton)
|
||||
val devicePropertiesMock: DeviceProperties = mock()
|
||||
whenever(mockDeviceProfile.deviceProperties).thenReturn(devicePropertiesMock)
|
||||
|
||||
// Init top level layout
|
||||
whenever(mockParentButtonContainer.requireViewById<LinearLayout>(ID_END_NAV_BUTTONS))
|
||||
@@ -73,7 +76,7 @@ class NavButtonLayoutFactoryTest {
|
||||
isInSetup = false,
|
||||
isThreeButtonNav = false,
|
||||
phoneMode = false,
|
||||
surfaceRotation = surfaceRotation
|
||||
surfaceRotation = surfaceRotation,
|
||||
)
|
||||
assert(layoutter is KidsNavLayoutter)
|
||||
}
|
||||
@@ -88,7 +91,7 @@ class NavButtonLayoutFactoryTest {
|
||||
isInSetup = true,
|
||||
isThreeButtonNav = false,
|
||||
phoneMode = false,
|
||||
surfaceRotation = surfaceRotation
|
||||
surfaceRotation = surfaceRotation,
|
||||
)
|
||||
assert(layoutter is SetupNavLayoutter)
|
||||
}
|
||||
@@ -103,7 +106,7 @@ class NavButtonLayoutFactoryTest {
|
||||
isInSetup = false,
|
||||
isThreeButtonNav = false,
|
||||
phoneMode = false,
|
||||
surfaceRotation = surfaceRotation
|
||||
surfaceRotation = surfaceRotation,
|
||||
)
|
||||
assert(layoutter is TaskbarNavLayoutter)
|
||||
}
|
||||
@@ -117,7 +120,7 @@ class NavButtonLayoutFactoryTest {
|
||||
isInSetup = false,
|
||||
isThreeButtonNav = false,
|
||||
phoneMode = false,
|
||||
surfaceRotation = surfaceRotation
|
||||
surfaceRotation = surfaceRotation,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -131,7 +134,7 @@ class NavButtonLayoutFactoryTest {
|
||||
isInSetup = false,
|
||||
isThreeButtonNav = true,
|
||||
phoneMode = true,
|
||||
surfaceRotation = surfaceRotation
|
||||
surfaceRotation = surfaceRotation,
|
||||
)
|
||||
assert(layoutter is PhonePortraitNavLayoutter)
|
||||
}
|
||||
@@ -147,7 +150,7 @@ class NavButtonLayoutFactoryTest {
|
||||
isInSetup = false,
|
||||
isThreeButtonNav = true,
|
||||
phoneMode = true,
|
||||
surfaceRotation = surfaceRotation
|
||||
surfaceRotation = surfaceRotation,
|
||||
)
|
||||
assert(layoutter is PhoneLandscapeNavLayoutter)
|
||||
}
|
||||
@@ -163,7 +166,7 @@ class NavButtonLayoutFactoryTest {
|
||||
isInSetup = false,
|
||||
isThreeButtonNav = true,
|
||||
phoneMode = true,
|
||||
surfaceRotation = ROTATION_270
|
||||
surfaceRotation = ROTATION_270,
|
||||
)
|
||||
assert(layoutter is PhoneSeascapeNavLayoutter)
|
||||
}
|
||||
@@ -178,16 +181,13 @@ class NavButtonLayoutFactoryTest {
|
||||
isInSetup = false,
|
||||
isThreeButtonNav = false,
|
||||
phoneMode = true,
|
||||
surfaceRotation = surfaceRotation
|
||||
surfaceRotation = surfaceRotation,
|
||||
)
|
||||
assert(layoutter is PhoneGestureLayoutter)
|
||||
}
|
||||
|
||||
private fun setDeviceProfileLandscape() {
|
||||
// Use reflection to modify landscape field
|
||||
val landscapeField = mockDeviceProfile.javaClass.getDeclaredField("isLandscape")
|
||||
landscapeField.isAccessible = true
|
||||
landscapeField.set(mockDeviceProfile, true)
|
||||
whenever(mockDeviceProfile.deviceProperties.isLandscape).thenReturn(true)
|
||||
}
|
||||
|
||||
private fun getLayoutter(
|
||||
@@ -195,7 +195,7 @@ class NavButtonLayoutFactoryTest {
|
||||
isInSetup: Boolean,
|
||||
isThreeButtonNav: Boolean,
|
||||
phoneMode: Boolean,
|
||||
@Rotation surfaceRotation: Int
|
||||
@Rotation surfaceRotation: Int,
|
||||
): NavButtonLayoutFactory.NavButtonLayoutter {
|
||||
return NavButtonLayoutFactory.getUiLayoutter(
|
||||
deviceProfile = mockDeviceProfile,
|
||||
|
||||
+16
-3
@@ -21,6 +21,7 @@ import com.android.quickstep.RecentsModel.RecentTasksChangedListener
|
||||
import com.android.quickstep.TaskIconCache
|
||||
import com.android.quickstep.TaskThumbnailCache
|
||||
import com.android.quickstep.util.GroupTask
|
||||
import java.util.function.BiConsumer
|
||||
import java.util.function.Consumer
|
||||
import org.mockito.kotlin.any
|
||||
import org.mockito.kotlin.anyOrNull
|
||||
@@ -42,16 +43,28 @@ class MockedRecentsModelHelper {
|
||||
|
||||
on { thumbnailCache } doReturn mockThumbnailCache
|
||||
|
||||
on { unregisterRecentTasksChangedListener() } doAnswer { recentTasksChangedListener = null }
|
||||
on { unregisterRecentTasksChangedListener(any()) } doAnswer
|
||||
{
|
||||
recentTasksChangedListener = null
|
||||
}
|
||||
|
||||
on { registerRecentTasksChangedListener(any<RecentTasksChangedListener>()) } doAnswer
|
||||
{
|
||||
recentTasksChangedListener = it.getArgument<RecentTasksChangedListener>(0)
|
||||
}
|
||||
|
||||
on { getTasks(anyOrNull(), anyOrNull()) } doAnswer
|
||||
on { getTasks(anyOrNull<BiConsumer<List<GroupTask>, Int>>(), anyOrNull()) } doAnswer
|
||||
{
|
||||
val request = it.getArgument<Consumer<List<GroupTask>>?>(0)
|
||||
val request = it.getArgument<BiConsumer<List<GroupTask>, Int>?>(0)
|
||||
if (request != null) {
|
||||
taskRequests.add { response -> request.accept(response, taskListId) }
|
||||
}
|
||||
taskListId
|
||||
}
|
||||
|
||||
on { getTasks(anyOrNull(), anyOrNull<Consumer<List<GroupTask>>>()) } doAnswer
|
||||
{
|
||||
val request = it.getArgument<Consumer<List<GroupTask>>?>(1)
|
||||
if (request != null) {
|
||||
taskRequests.add { response -> request.accept(response) }
|
||||
}
|
||||
|
||||
+6
-6
@@ -49,8 +49,8 @@ class TaskbarModeRuleTest {
|
||||
@TaskbarMode(TRANSIENT)
|
||||
fun testTaskbarMode_transient_overridesDeviceProfile() {
|
||||
val dp = InvariantDeviceProfile.INSTANCE.get(context).getDeviceProfile(context)
|
||||
assertThat(dp.isTransientTaskbar).isTrue()
|
||||
assertThat(dp.isGestureMode).isTrue()
|
||||
assertThat(dp.taskbarProfile.isTransientTaskbar).isTrue()
|
||||
assertThat(dp.deviceProperties.isGestureMode).isTrue()
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -65,8 +65,8 @@ class TaskbarModeRuleTest {
|
||||
@TaskbarMode(PINNED)
|
||||
fun testTaskbarMode_pinned_overridesDeviceProfile() {
|
||||
val dp = InvariantDeviceProfile.INSTANCE.get(context).getDeviceProfile(context)
|
||||
assertThat(dp.isTransientTaskbar).isFalse()
|
||||
assertThat(dp.isGestureMode).isTrue()
|
||||
assertThat(dp.taskbarProfile.isTransientTaskbar).isFalse()
|
||||
assertThat(dp.deviceProperties.isGestureMode).isTrue()
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -82,7 +82,7 @@ class TaskbarModeRuleTest {
|
||||
@TaskbarMode(THREE_BUTTONS)
|
||||
fun testTaskbarMode_threeButtons_overridesDeviceProfile() {
|
||||
val dp = InvariantDeviceProfile.INSTANCE.get(context).getDeviceProfile(context)
|
||||
assertThat(dp.isTransientTaskbar).isFalse()
|
||||
assertThat(dp.isGestureMode).isFalse()
|
||||
assertThat(dp.taskbarProfile.isTransientTaskbar).isFalse()
|
||||
assertThat(dp.deviceProperties.isGestureMode).isFalse()
|
||||
}
|
||||
}
|
||||
+48
-6
@@ -26,15 +26,18 @@ import androidx.test.platform.app.InstrumentationRegistry
|
||||
import com.android.launcher3.LauncherAppState
|
||||
import com.android.launcher3.taskbar.TaskbarActivityContext
|
||||
import com.android.launcher3.taskbar.TaskbarControllers
|
||||
import com.android.launcher3.taskbar.TaskbarManager
|
||||
import com.android.launcher3.taskbar.TaskbarManagerImpl
|
||||
import com.android.launcher3.taskbar.TaskbarNavButtonController.TaskbarNavButtonCallbacks
|
||||
import com.android.launcher3.taskbar.TaskbarUIController
|
||||
import com.android.launcher3.taskbar.bubbles.BubbleControllers
|
||||
import com.android.launcher3.taskbar.rules.TaskbarUnitTestRule.InjectController
|
||||
import com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR
|
||||
import com.android.launcher3.util.TestUtil
|
||||
import com.android.launcher3.util.coroutines.ProductionDispatchers
|
||||
import com.android.quickstep.AllAppsActionManager
|
||||
import com.android.quickstep.fallback.window.RecentsDisplayModel
|
||||
import com.android.quickstep.LauncherDisplaysWithDecorationsRepositoryCompat
|
||||
import com.android.quickstep.fallback.window.RecentsWindowManager
|
||||
import com.android.quickstep.input.QuickstepKeyGestureEventsManager
|
||||
import java.lang.reflect.Field
|
||||
import java.lang.reflect.ParameterizedType
|
||||
import java.util.Locale
|
||||
@@ -43,6 +46,10 @@ import org.junit.Assume.assumeTrue
|
||||
import org.junit.rules.TestRule
|
||||
import org.junit.runner.Description
|
||||
import org.junit.runners.model.Statement
|
||||
import org.mockito.kotlin.any
|
||||
import org.mockito.kotlin.doNothing
|
||||
import org.mockito.kotlin.spy
|
||||
import org.mockito.kotlin.whenever
|
||||
|
||||
/**
|
||||
* Manages the Taskbar lifecycle for unit tests.
|
||||
@@ -78,7 +85,7 @@ class TaskbarUnitTestRule(
|
||||
|
||||
private val instrumentation = InstrumentationRegistry.getInstrumentation()
|
||||
|
||||
private lateinit var taskbarManager: TaskbarManager
|
||||
private lateinit var taskbarManager: TaskbarManagerImpl
|
||||
|
||||
val activityContext: TaskbarActivityContext
|
||||
get() {
|
||||
@@ -103,16 +110,38 @@ class TaskbarUnitTestRule(
|
||||
context.settingsCacheSandbox[getUriFor(NAV_BAR_KIDS_MODE)] =
|
||||
if (description.getAnnotation(NavBarKidsMode::class.java) != null) 1 else 0
|
||||
|
||||
val quickstepKeyGestureEventsManagerSpy =
|
||||
spy(QuickstepKeyGestureEventsManager(context))
|
||||
doNothing()
|
||||
.whenever(quickstepKeyGestureEventsManagerSpy)
|
||||
.registerAllAppsKeyGestureEvent(any())
|
||||
doNothing()
|
||||
.whenever(quickstepKeyGestureEventsManagerSpy)
|
||||
.unregisterAllAppsKeyGestureEvent()
|
||||
doNothing()
|
||||
.whenever(quickstepKeyGestureEventsManagerSpy)
|
||||
.registerOverviewKeyGestureEvent(any())
|
||||
doNothing()
|
||||
.whenever(quickstepKeyGestureEventsManagerSpy)
|
||||
.unregisterOverviewKeyGestureEvent()
|
||||
taskbarManager =
|
||||
TestUtil.getOnUiThread {
|
||||
object :
|
||||
TaskbarManager(
|
||||
TaskbarManagerImpl(
|
||||
context,
|
||||
AllAppsActionManager(context, UI_HELPER_EXECUTOR) {
|
||||
AllAppsActionManager(
|
||||
context,
|
||||
UI_HELPER_EXECUTOR,
|
||||
quickstepKeyGestureEventsManagerSpy,
|
||||
) {
|
||||
PendingIntent(IIntentSender.Default())
|
||||
},
|
||||
object : TaskbarNavButtonCallbacks {},
|
||||
RecentsDisplayModel.INSTANCE.get(context),
|
||||
RecentsWindowManager.REPOSITORY_INSTANCE.get(context),
|
||||
LauncherDisplaysWithDecorationsRepositoryCompat.INSTANCE.get(
|
||||
context
|
||||
),
|
||||
ProductionDispatchers.main,
|
||||
) {
|
||||
override fun recreateTaskbars() {
|
||||
super.recreateTaskbars()
|
||||
@@ -123,6 +152,18 @@ class TaskbarUnitTestRule(
|
||||
controllerInjectionCallback.invoke()
|
||||
}
|
||||
}
|
||||
|
||||
override fun recreateTaskbarForDisplay(displayId: Int, duration: Int) {
|
||||
super.recreateTaskbarForDisplay(displayId, duration)
|
||||
if (
|
||||
displayId == context.displayId && currentActivityContext != null
|
||||
) {
|
||||
injectControllers()
|
||||
// TODO(b/346394875): we should test a non-default uiController.
|
||||
activityContext.setUIController(TaskbarUIController.DEFAULT)
|
||||
controllerInjectionCallback.invoke()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,6 +184,7 @@ class TaskbarUnitTestRule(
|
||||
base.evaluate()
|
||||
} finally {
|
||||
instrumentation.runOnMainSync { taskbarManager.destroy() }
|
||||
context.displayControllerSpy?.cleanup()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+18
-77
@@ -20,34 +20,18 @@ import android.content.Context
|
||||
import android.content.ContextWrapper
|
||||
import android.hardware.display.DisplayManager
|
||||
import android.hardware.display.VirtualDisplay
|
||||
import android.view.Display
|
||||
import android.view.Display.DEFAULT_DISPLAY
|
||||
import androidx.test.core.app.ApplicationProvider
|
||||
import com.android.launcher3.LauncherPrefs
|
||||
import com.android.launcher3.dagger.ApplicationContext
|
||||
import com.android.launcher3.dagger.LauncherAppComponent
|
||||
import com.android.launcher3.dagger.LauncherAppSingleton
|
||||
import com.android.launcher3.statehandlers.DesktopVisibilityController
|
||||
import com.android.launcher3.util.AllModulesMinusWMProxy
|
||||
import com.android.launcher3.util.DaggerSingletonTracker
|
||||
import com.android.launcher3.util.DisplayController
|
||||
import com.android.launcher3.util.FakePrefsModule
|
||||
import com.android.launcher3.util.SandboxApplication
|
||||
import com.android.launcher3.util.SettingsCache
|
||||
import com.android.launcher3.util.SettingsCacheSandbox
|
||||
import com.android.launcher3.util.window.WindowManagerProxy
|
||||
import com.android.quickstep.SystemUiProxy
|
||||
import dagger.Binds
|
||||
import dagger.BindsInstance
|
||||
import dagger.Component
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import javax.inject.Inject
|
||||
import org.junit.rules.ExternalResource
|
||||
import org.junit.rules.RuleChain
|
||||
import org.junit.rules.TestRule
|
||||
import org.junit.runner.Description
|
||||
import org.junit.runners.model.Statement
|
||||
import org.mockito.kotlin.spy
|
||||
import org.mockito.kotlin.whenever
|
||||
|
||||
/**
|
||||
* [SandboxApplication] for running Taskbar tests.
|
||||
@@ -69,6 +53,20 @@ private constructor(
|
||||
override fun after() = virtualDisplay.release()
|
||||
}
|
||||
|
||||
// Filter out DEFAULT_DISPLAY in case code accesses displays property. The primary virtual
|
||||
// display has a different ID.
|
||||
private val sandboxDisplayManagerRule =
|
||||
object : ExternalResource() {
|
||||
override fun before() {
|
||||
val dm = base.spyService(DisplayManager::class.java)
|
||||
whenever(dm.displays).thenAnswer { i ->
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val displays = i.callRealMethod() as? Array<Display> ?: emptyArray<Display>()
|
||||
displays.filter { it.displayId != DEFAULT_DISPLAY }.toTypedArray()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private val singletonSetupRule =
|
||||
object : ExternalResource() {
|
||||
override fun before() {
|
||||
@@ -84,6 +82,7 @@ private constructor(
|
||||
override fun apply(statement: Statement, description: Description): Statement {
|
||||
return RuleChain.outerRule(virtualDisplayRule)
|
||||
.around(base)
|
||||
.around(sandboxDisplayManagerRule)
|
||||
.around(singletonSetupRule)
|
||||
.apply(statement, description)
|
||||
}
|
||||
@@ -109,7 +108,7 @@ private constructor(
|
||||
}
|
||||
|
||||
return TaskbarWindowSandboxContext(
|
||||
SandboxApplication(base.createDisplayContext(virtualDisplay.display)),
|
||||
SandboxApplication(base = base.createDisplayContext(virtualDisplay.display)),
|
||||
virtualDisplay,
|
||||
params,
|
||||
)
|
||||
@@ -117,64 +116,6 @@ private constructor(
|
||||
}
|
||||
}
|
||||
|
||||
/** A wrapper over display controller which allows modifying the underlying info */
|
||||
@LauncherAppSingleton
|
||||
class DisplayControllerSpy
|
||||
@Inject
|
||||
constructor(
|
||||
@ApplicationContext context: Context,
|
||||
wmProxy: WindowManagerProxy,
|
||||
prefs: LauncherPrefs,
|
||||
lifecycle: DaggerSingletonTracker,
|
||||
) : DisplayController(context, wmProxy, prefs, lifecycle) {
|
||||
|
||||
var infoModifier: ((Info) -> Info)? = null
|
||||
|
||||
override fun getInfo(): Info = infoModifier?.invoke(super.getInfo()) ?: super.getInfo()
|
||||
}
|
||||
|
||||
@Module
|
||||
abstract class DisplayControllerModule {
|
||||
@Binds abstract fun bindDisplayController(controller: DisplayControllerSpy): DisplayController
|
||||
}
|
||||
|
||||
@Module
|
||||
object DesktopVisibilityControllerModule {
|
||||
@JvmStatic
|
||||
@Provides
|
||||
@LauncherAppSingleton
|
||||
fun provideDesktopVisibilityController(
|
||||
@ApplicationContext context: Context,
|
||||
systemUiProxy: SystemUiProxy,
|
||||
lifecycleTracker: DaggerSingletonTracker,
|
||||
): DesktopVisibilityController {
|
||||
return spy(DesktopVisibilityController(context, systemUiProxy, lifecycleTracker))
|
||||
}
|
||||
}
|
||||
|
||||
@LauncherAppSingleton
|
||||
@Component(
|
||||
modules =
|
||||
[
|
||||
AllModulesMinusWMProxy::class,
|
||||
FakePrefsModule::class,
|
||||
DisplayControllerModule::class,
|
||||
TaskbarSandboxModule::class,
|
||||
DesktopVisibilityControllerModule::class,
|
||||
]
|
||||
)
|
||||
interface TaskbarSandboxComponent : LauncherAppComponent {
|
||||
|
||||
@Component.Builder
|
||||
interface Builder : LauncherAppComponent.Builder {
|
||||
@BindsInstance fun bindSystemUiProxy(proxy: SystemUiProxy): Builder
|
||||
|
||||
@BindsInstance fun bindSettingsCache(settingsCache: SettingsCache): Builder
|
||||
|
||||
override fun build(): TaskbarSandboxComponent
|
||||
}
|
||||
}
|
||||
|
||||
/** Include additional bindings when building a [TaskbarSandboxComponent]. */
|
||||
data class SandboxParams(
|
||||
val systemUiProxyProvider: (Context) -> SystemUiProxy = { SystemUiProxy(it) },
|
||||
|
||||
+135
-23
@@ -18,12 +18,16 @@ package com.android.quickstep;
|
||||
|
||||
import static android.view.Display.DEFAULT_DISPLAY;
|
||||
|
||||
import static com.android.launcher3.BaseActivity.EVENT_DESTROYED;
|
||||
import static com.android.launcher3.statehandlers.DesktopVisibilityController.INACTIVE_DESK_ID;
|
||||
import static com.android.quickstep.AbsSwipeUpHandler.STATE_HANDLER_INVALIDATED;
|
||||
import static com.android.wm.shell.shared.ShellSharedConstants.KEY_EXTRA_SHELL_CAN_HAND_OFF_ANIMATION;
|
||||
import static com.android.wm.shell.shared.split.SplitBounds.KEY_EXTRA_SPLIT_BOUNDS;
|
||||
import static com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_2_50_50;
|
||||
|
||||
import static junit.framework.Assert.assertNotNull;
|
||||
import static junit.framework.TestCase.assertFalse;
|
||||
import static junit.framework.TestCase.assertNull;
|
||||
import static junit.framework.TestCase.assertTrue;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
@@ -33,7 +37,9 @@ import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.atLeast;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
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;
|
||||
@@ -51,7 +57,6 @@ import android.os.SystemClock;
|
||||
import android.platform.test.annotations.DisableFlags;
|
||||
import android.platform.test.annotations.EnableFlags;
|
||||
import android.platform.test.flag.junit.SetFlagsRule;
|
||||
import android.view.Display;
|
||||
import android.view.RemoteAnimationTarget;
|
||||
import android.view.SurfaceControl;
|
||||
import android.view.ViewTreeObserver;
|
||||
@@ -63,9 +68,10 @@ 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.LauncherModelHelper;
|
||||
import com.android.launcher3.util.MSDLPlayerWrapper;
|
||||
import com.android.launcher3.util.SandboxApplication;
|
||||
import com.android.launcher3.util.SystemUiController;
|
||||
import com.android.quickstep.util.ContextInitListener;
|
||||
import com.android.quickstep.util.MotionPauseDetector;
|
||||
@@ -78,6 +84,7 @@ import com.android.wm.shell.shared.split.SplitBounds;
|
||||
import com.google.android.msdl.data.model.MSDLToken;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
@@ -95,17 +102,23 @@ public abstract class AbsSwipeUpHandlerTestCase<
|
||||
SWIPE_HANDLER extends AbsSwipeUpHandler<RECENTS_CONTAINER, RECENTS_VIEW, STATE_TYPE>,
|
||||
CONTAINER_INTERFACE extends BaseContainerInterface<STATE_TYPE, RECENTS_CONTAINER>> {
|
||||
|
||||
protected final LauncherModelHelper mLauncherModelHelper = new LauncherModelHelper();
|
||||
protected final LauncherModelHelper.SandboxModelContext mContext =
|
||||
mLauncherModelHelper.sandboxContext;
|
||||
@Rule
|
||||
public final MockitoRule mMockitoRule = MockitoJUnit.rule();
|
||||
|
||||
@Rule
|
||||
public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
|
||||
|
||||
@Rule
|
||||
public final SandboxApplication mContext = new SandboxApplication();
|
||||
|
||||
protected final InputConsumerController mInputConsumerController =
|
||||
InputConsumerController.getRecentsAnimationInputConsumer();
|
||||
protected final ActivityManager.RunningTaskInfo mRunningTaskInfo =
|
||||
new ActivityManager.RunningTaskInfo();
|
||||
protected final TopTaskTracker.CachedTaskInfo mCachedTaskInfo =
|
||||
new TopTaskTracker.CachedTaskInfo(
|
||||
Collections.singletonList(mRunningTaskInfo), /* canEnterDesktop = */ false,
|
||||
DEFAULT_DISPLAY);
|
||||
Collections.singletonList(mRunningTaskInfo), mContext, DEFAULT_DISPLAY,
|
||||
INACTIVE_DESK_ID);
|
||||
protected final RemoteAnimationTarget mRemoteAnimationTarget = new RemoteAnimationTarget(
|
||||
/* taskId= */ 0,
|
||||
/* mode= */ RemoteAnimationTarget.MODE_CLOSING,
|
||||
@@ -124,8 +137,45 @@ public abstract class AbsSwipeUpHandlerTestCase<
|
||||
/* taskInfo= */ mRunningTaskInfo,
|
||||
/* allowEnterPip= */ false);
|
||||
|
||||
protected final RemoteAnimationTarget mRemoteAnimationLeftTop = new RemoteAnimationTarget(
|
||||
/* taskId= */ 1,
|
||||
/* mode= */ RemoteAnimationTarget.MODE_CLOSING,
|
||||
/* leash= */ new SurfaceControl(),
|
||||
/* isTranslucent= */ false,
|
||||
/* clipRect= */ null,
|
||||
/* contentInsets= */ null,
|
||||
/* prefixOrderIndex= */ 0,
|
||||
/* position= */ null,
|
||||
/* localBounds= */ null,
|
||||
/* screenSpaceBounds= */ null,
|
||||
new Configuration().windowConfiguration,
|
||||
/* isNotInRecents= */ false,
|
||||
/* startLeash= */ null,
|
||||
/* startBounds= */ null,
|
||||
/* taskInfo= */ mRunningTaskInfo,
|
||||
/* allowEnterPip= */ false);
|
||||
|
||||
protected final RemoteAnimationTarget mRemoteAnimationRightBottom = new RemoteAnimationTarget(
|
||||
/* taskId= */ 2,
|
||||
/* mode= */ RemoteAnimationTarget.MODE_CLOSING,
|
||||
/* leash= */ new SurfaceControl(),
|
||||
/* isTranslucent= */ false,
|
||||
/* clipRect= */ null,
|
||||
/* contentInsets= */ null,
|
||||
/* prefixOrderIndex= */ 0,
|
||||
/* position= */ null,
|
||||
/* localBounds= */ null,
|
||||
/* screenSpaceBounds= */ null,
|
||||
new Configuration().windowConfiguration,
|
||||
/* isNotInRecents= */ false,
|
||||
/* startLeash= */ null,
|
||||
/* startBounds= */ null,
|
||||
/* taskInfo= */ mRunningTaskInfo,
|
||||
/* allowEnterPip= */ false);
|
||||
|
||||
protected RecentsAnimationTargets mRecentsAnimationTargets;
|
||||
protected TaskAnimationManager mTaskAnimationManager;
|
||||
protected StateManager<STATE_TYPE, RECENTS_CONTAINER> mStateManager;
|
||||
|
||||
@Mock protected CONTAINER_INTERFACE mActivityInterface;
|
||||
@Mock protected ContextInitListener<?> mContextInitListener;
|
||||
@@ -137,12 +187,9 @@ public abstract class AbsSwipeUpHandlerTestCase<
|
||||
@Mock protected SystemUiController mSystemUiController;
|
||||
@Mock protected GestureState mGestureState;
|
||||
@Mock protected MSDLPlayerWrapper mMSDLPlayerWrapper;
|
||||
|
||||
@Rule
|
||||
public final MockitoRule mMockitoRule = MockitoJUnit.rule();
|
||||
|
||||
@Rule
|
||||
public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
|
||||
@Mock protected RecentsAnimationDeviceState mDeviceState;
|
||||
@Mock protected RotationTouchHelper mRotationTouchHelper;
|
||||
@Mock protected StateManager.AtomicAnimationFactory<STATE_TYPE> mAtomicAnimationFactory;
|
||||
|
||||
@Before
|
||||
public void setUpAnimationTargets() {
|
||||
@@ -151,12 +198,12 @@ public abstract class AbsSwipeUpHandlerTestCase<
|
||||
extras.putParcelable(KEY_EXTRA_SPLIT_BOUNDS, new SplitBounds(
|
||||
/* leftTopBounds = */ new Rect(),
|
||||
/* rightBottomBounds = */ new Rect(),
|
||||
/* leftTopTaskId = */ -1,
|
||||
/* rightBottomTaskId = */ -1,
|
||||
/* leftTopTaskId = */ mRemoteAnimationLeftTop.taskId,
|
||||
/* rightBottomTaskId = */ mRemoteAnimationRightBottom.taskId,
|
||||
/* snapPosition = */ SNAP_TO_2_50_50));
|
||||
mRecentsAnimationTargets = new RecentsAnimationTargets(
|
||||
new RemoteAnimationTarget[] {mRemoteAnimationTarget},
|
||||
new RemoteAnimationTarget[] {mRemoteAnimationTarget},
|
||||
new RemoteAnimationTarget[] {mRemoteAnimationLeftTop},
|
||||
new RemoteAnimationTarget[] {mRemoteAnimationRightBottom},
|
||||
new RemoteAnimationTarget[] {mRemoteAnimationTarget},
|
||||
/* homeContentInsets= */ new Rect(),
|
||||
/* minimizedHomeBounds= */ null,
|
||||
@@ -193,9 +240,8 @@ public abstract class AbsSwipeUpHandlerTestCase<
|
||||
|
||||
@Before
|
||||
public void setUpRecentsContainer() {
|
||||
mTaskAnimationManager = new TaskAnimationManager(mContext,
|
||||
RecentsAnimationDeviceState.INSTANCE.get(mContext), DEFAULT_DISPLAY);
|
||||
RecentsViewContainer recentsContainer = getRecentsContainer();
|
||||
mTaskAnimationManager = spy(new TaskAnimationManager(mContext, DEFAULT_DISPLAY));
|
||||
RECENTS_CONTAINER recentsContainer = getRecentsContainer();
|
||||
RECENTS_VIEW recentsView = getRecentsView();
|
||||
|
||||
when(recentsContainer.getDeviceProfile()).thenReturn(new DeviceProfile());
|
||||
@@ -203,6 +249,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();
|
||||
@@ -210,6 +257,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
|
||||
@@ -319,6 +370,24 @@ public abstract class AbsSwipeUpHandlerTestCase<
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore("b/418979038")
|
||||
public void invalidateHandlerWithLauncher_runsGestureAnimationEndCallback() {
|
||||
SWIPE_HANDLER handler = createSwipeHandler();
|
||||
Runnable onGestureAnimationEndCallback = mock(Runnable.class);
|
||||
handler.setGestureAnimationEndCallback(onGestureAnimationEndCallback);
|
||||
handler.onActivityInit(true); // Sets STATE_LAUNCHER_PRESENT
|
||||
|
||||
// Use onConsumerAboutToBeSwitched to call reset(),to sets STATE_HANDLER_INVALIDATED. This
|
||||
// will then call invalidateHandlerWithLauncher. This will hit the reset() in the else
|
||||
// condition of onConsumerAboutToBeSwitched, as the gesture state is a mock and will
|
||||
// return false for the booleans checked in the if-condition.
|
||||
handler.onConsumerAboutToBeSwitched();
|
||||
|
||||
verify(getRecentsView()).onGestureAnimationEnd();
|
||||
verify(onGestureAnimationEndCallback).run();
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(com.android.launcher3.Flags.FLAG_MSDL_FEEDBACK)
|
||||
public void onMotionPauseDetected_playsSwipeThresholdToken() {
|
||||
@@ -330,6 +399,39 @@ public abstract class AbsSwipeUpHandlerTestCase<
|
||||
verifyNoMoreInteractions(mMSDLPlayerWrapper);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnContainerDestroy_cleansUpSwipeHandler() {
|
||||
SWIPE_HANDLER swipeHandler = createSwipeHandler();
|
||||
|
||||
swipeHandler.onActivityInit(true);
|
||||
|
||||
RECENTS_CONTAINER container = getRecentsContainer();
|
||||
ArgumentCaptor<Runnable> onContainerDestroyCallbackCaptor =
|
||||
ArgumentCaptor.forClass(Runnable.class);
|
||||
|
||||
verify(container)
|
||||
.addEventCallback(eq(EVENT_DESTROYED), onContainerDestroyCallbackCaptor.capture());
|
||||
|
||||
assertNotNull(swipeHandler.mRecentsView);
|
||||
assertNotNull(swipeHandler.mContainer);
|
||||
|
||||
onContainerDestroyCallbackCaptor.getValue().run();
|
||||
|
||||
assertNull(swipeHandler.mRecentsView);
|
||||
assertNull(swipeHandler.mContainer);
|
||||
verify(mTaskAnimationManager).onLauncherDestroyed();
|
||||
runOnMainSync(() -> verify(mContextInitListener)
|
||||
.unregister(eq("AbsSwipeUpHandler.mLauncherOnDestroyCallback")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_noActivityInit_doesNotThrowException() {
|
||||
// Do not trigger onActivityInit to ensure AbsSwipeUpHandler.mRecentsView and
|
||||
// AbsSwipeUpHandler.mContainer are null
|
||||
createSwipeUpHandlerForGesture(
|
||||
GestureState.GestureEndTarget.HOME, /* triggerOnActivityInit= */ false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that RecentsAnimationController#finish() is called, and captures and runs any
|
||||
* callback that was passed to it. This ensures that STATE_CURRENT_TASK_FINISHED is correctly
|
||||
@@ -351,13 +453,20 @@ public abstract class AbsSwipeUpHandlerTestCase<
|
||||
}
|
||||
|
||||
private SWIPE_HANDLER createSwipeUpHandlerForGesture(GestureState.GestureEndTarget endTarget) {
|
||||
return createSwipeUpHandlerForGesture(endTarget, true);
|
||||
}
|
||||
|
||||
private SWIPE_HANDLER createSwipeUpHandlerForGesture(
|
||||
GestureState.GestureEndTarget endTarget, boolean triggerOnActivityInit) {
|
||||
boolean isQuickSwitch = endTarget == GestureState.GestureEndTarget.NEW_TASK;
|
||||
|
||||
doReturn(mState).when(mActivityInterface).stateFromGestureEndTarget(any());
|
||||
|
||||
SWIPE_HANDLER swipeHandler = createSwipeHandler(SystemClock.uptimeMillis(), isQuickSwitch);
|
||||
|
||||
swipeHandler.onActivityInit(/* alreadyOnHome= */ false);
|
||||
if (triggerOnActivityInit) {
|
||||
swipeHandler.onActivityInit(/* alreadyOnHome= */ false);
|
||||
}
|
||||
swipeHandler.onGestureStarted(isQuickSwitch);
|
||||
onRecentsAnimationStart(swipeHandler);
|
||||
|
||||
@@ -378,7 +487,7 @@ public abstract class AbsSwipeUpHandlerTestCase<
|
||||
|
||||
private void onRecentsAnimationStart(SWIPE_HANDLER absSwipeUpHandler) {
|
||||
runOnMainSync(() -> absSwipeUpHandler.onRecentsAnimationStart(
|
||||
mRecentsAnimationController, mRecentsAnimationTargets, /* transitionInfo= */null));
|
||||
mRecentsAnimationController, mRecentsAnimationTargets, /* transitionInfo= */ null));
|
||||
}
|
||||
|
||||
protected static void runOnMainSync(Runnable runnable) {
|
||||
@@ -395,8 +504,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();
|
||||
}
|
||||
+32
-2
@@ -18,6 +18,7 @@ package com.android.quickstep
|
||||
|
||||
import android.app.PendingIntent
|
||||
import android.content.IIntentSender
|
||||
import android.hardware.input.InputManager
|
||||
import android.provider.Settings
|
||||
import android.provider.Settings.Secure.USER_SETUP_COMPLETE
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
@@ -29,6 +30,7 @@ import com.android.launcher3.util.SandboxApplication
|
||||
import com.android.launcher3.util.SettingsCache
|
||||
import com.android.launcher3.util.SettingsCacheSandbox
|
||||
import com.android.launcher3.util.TestUtil
|
||||
import com.android.quickstep.input.QuickstepKeyGestureEventsManager
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import dagger.BindsInstance
|
||||
import dagger.Component
|
||||
@@ -39,6 +41,11 @@ import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Mockito.spy
|
||||
import org.mockito.Mockito.verify
|
||||
import org.mockito.kotlin.any
|
||||
import org.mockito.kotlin.doNothing
|
||||
import org.mockito.kotlin.whenever
|
||||
|
||||
private const val TIMEOUT = 5L
|
||||
private val USER_SETUP_COMPLETE_URI = Settings.Secure.getUriFor(USER_SETUP_COMPLETE)
|
||||
@@ -49,24 +56,30 @@ class AllAppsActionManagerTest {
|
||||
private val bgExecutor = UI_HELPER_EXECUTOR
|
||||
|
||||
@get:Rule val context = SandboxApplication()
|
||||
private val inputManager = context.spyService(InputManager::class.java)
|
||||
|
||||
private val settingsCacheSandbox =
|
||||
SettingsCacheSandbox().also { it[USER_SETUP_COMPLETE_URI] = 1 }
|
||||
private val quickstepKeyGestureEventsManager by
|
||||
lazy(LazyThreadSafetyMode.NONE) { spy(QuickstepKeyGestureEventsManager(context)) }
|
||||
|
||||
private val allAppsActionManager by
|
||||
lazy(LazyThreadSafetyMode.NONE) {
|
||||
AllAppsActionManager(context, bgExecutor) {
|
||||
AllAppsActionManager(context, bgExecutor, quickstepKeyGestureEventsManager) {
|
||||
callbackSemaphore.release()
|
||||
PendingIntent(IIntentSender.Default())
|
||||
}
|
||||
}
|
||||
|
||||
@Before
|
||||
fun initDaggerComponent() {
|
||||
fun setUp() {
|
||||
context.initDaggerComponent(
|
||||
DaggerAllAppsActionManagerTestComponent.builder()
|
||||
.bindSettingsCache(settingsCacheSandbox.cache)
|
||||
)
|
||||
|
||||
doNothing().whenever(inputManager).registerKeyGestureEventHandler(any(), any())
|
||||
doNothing().whenever(inputManager).unregisterKeyGestureEventHandler(any())
|
||||
}
|
||||
|
||||
@After fun destroyManager() = allAppsActionManager.onDestroy()
|
||||
@@ -74,15 +87,19 @@ class AllAppsActionManagerTest {
|
||||
@Test
|
||||
fun taskbarPresent_actionRegistered() {
|
||||
allAppsActionManager.isTaskbarPresent = true
|
||||
TestUtil.runOnExecutorSync(bgExecutor) {} // Force system action to register.
|
||||
assertThat(callbackSemaphore.tryAcquire(TIMEOUT, SECONDS)).isTrue()
|
||||
assertThat(allAppsActionManager.isActionRegistered).isTrue()
|
||||
verify(quickstepKeyGestureEventsManager).registerAllAppsKeyGestureEvent(any())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun homeAndOverviewSame_actionRegistered() {
|
||||
allAppsActionManager.isHomeAndOverviewSame = true
|
||||
TestUtil.runOnExecutorSync(bgExecutor) {} // Force system action to register.
|
||||
assertThat(callbackSemaphore.tryAcquire(TIMEOUT, SECONDS)).isTrue()
|
||||
assertThat(allAppsActionManager.isActionRegistered).isTrue()
|
||||
verify(quickstepKeyGestureEventsManager).registerAllAppsKeyGestureEvent(any())
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -93,6 +110,7 @@ class AllAppsActionManagerTest {
|
||||
allAppsActionManager.isTaskbarPresent = false
|
||||
TestUtil.runOnExecutorSync(bgExecutor) {} // Force system action to unregister.
|
||||
assertThat(allAppsActionManager.isActionRegistered).isFalse()
|
||||
verify(quickstepKeyGestureEventsManager).unregisterAllAppsKeyGestureEvent()
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -103,6 +121,7 @@ class AllAppsActionManagerTest {
|
||||
TestUtil.runOnExecutorSync(bgExecutor) {} // Force system action to unregister.
|
||||
assertThat(callbackSemaphore.tryAcquire(TIMEOUT, SECONDS)).isTrue()
|
||||
assertThat(allAppsActionManager.isActionRegistered).isFalse()
|
||||
verify(quickstepKeyGestureEventsManager).unregisterAllAppsKeyGestureEvent()
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -136,8 +155,10 @@ class AllAppsActionManagerTest {
|
||||
allAppsActionManager.isTaskbarPresent = true
|
||||
|
||||
settingsCacheSandbox[USER_SETUP_COMPLETE_URI] = 1
|
||||
TestUtil.runOnExecutorSync(bgExecutor) {} // Force system action to register.
|
||||
assertThat(callbackSemaphore.tryAcquire(TIMEOUT, SECONDS)).isTrue()
|
||||
assertThat(allAppsActionManager.isActionRegistered).isTrue()
|
||||
verify(quickstepKeyGestureEventsManager).registerAllAppsKeyGestureEvent(any())
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -146,8 +167,17 @@ class AllAppsActionManagerTest {
|
||||
allAppsActionManager.isTaskbarPresent = true
|
||||
|
||||
allAppsActionManager.isSetupUiVisible = false
|
||||
TestUtil.runOnExecutorSync(bgExecutor) {} // Force system action to register.
|
||||
assertThat(callbackSemaphore.tryAcquire(TIMEOUT, SECONDS)).isTrue()
|
||||
assertThat(allAppsActionManager.isActionRegistered).isTrue()
|
||||
verify(quickstepKeyGestureEventsManager).registerAllAppsKeyGestureEvent(any())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun onDestroy_shouldUnregisterAllAppsKeyGestureHandler() {
|
||||
allAppsActionManager.onDestroy()
|
||||
|
||||
verify(quickstepKeyGestureEventsManager).unregisterAllAppsKeyGestureEvent()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,16 +21,23 @@ import android.view.Display
|
||||
import androidx.test.core.app.ApplicationProvider
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.filters.SmallTest
|
||||
import com.android.app.displaylib.DisplaysWithDecorationsRepositoryCompat
|
||||
import java.io.PrintWriter
|
||||
import kotlinx.coroutines.test.StandardTestDispatcher
|
||||
import org.junit.Assert.assertNotNull
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.kotlin.mock
|
||||
|
||||
@SmallTest
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class DisplayModelTest {
|
||||
private val context: Context = ApplicationProvider.getApplicationContext()
|
||||
private val systemDecorationChangeObserver =
|
||||
SystemDecorationChangeObserver.INSTANCE.get(context)
|
||||
private val displayRepositoryCompat = mock<DisplaysWithDecorationsRepositoryCompat>()
|
||||
private val dispatcher = StandardTestDispatcher()
|
||||
|
||||
class TestableResource : DisplayModel.DisplayResource() {
|
||||
var isCleanupCalled = false
|
||||
@@ -45,7 +52,13 @@ class DisplayModelTest {
|
||||
}
|
||||
|
||||
private val testableDisplayModel =
|
||||
object : DisplayModel<TestableResource>(context) {
|
||||
object :
|
||||
DisplayModel<TestableResource>(
|
||||
context,
|
||||
systemDecorationChangeObserver,
|
||||
displayRepositoryCompat,
|
||||
dispatcher,
|
||||
) {
|
||||
override fun createDisplayResource(display: Display): TestableResource {
|
||||
return TestableResource()
|
||||
}
|
||||
|
||||
+8
@@ -45,6 +45,8 @@ public class FallbackSwipeHandlerTestCase extends AbsSwipeUpHandlerTestCase<
|
||||
return new FallbackSwipeHandler(
|
||||
mContext,
|
||||
mTaskAnimationManager,
|
||||
mDeviceState,
|
||||
mRotationTouchHelper,
|
||||
mGestureState,
|
||||
touchTimeMs,
|
||||
continuingLastGesture,
|
||||
@@ -63,4 +65,10 @@ public class FallbackSwipeHandlerTestCase extends AbsSwipeUpHandlerTestCase<
|
||||
protected FallbackRecentsView<RecentsActivity> getRecentsView() {
|
||||
return mRecentsView;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected RecentsState getBaseState() {
|
||||
return RecentsState.BG_LAUNCHER;
|
||||
}
|
||||
}
|
||||
+7
-7
@@ -39,7 +39,7 @@ class HotseatWidthCalculationTest : FakeInvariantDeviceProfileTest() {
|
||||
val dp = newDP()
|
||||
dp.isTaskbarPresentInApps = true
|
||||
|
||||
assertThat(dp.hotseatBarEndOffset).isEqualTo(510)
|
||||
assertThat(dp.hotseatProfile.barEndOffset).isEqualTo(510)
|
||||
assertThat(dp.numShownHotseatIcons).isEqualTo(6)
|
||||
assertThat(dp.hotseatBorderSpace).isEqualTo(70)
|
||||
assertThat(dp.hotseatColumnSpan).isEqualTo(6)
|
||||
@@ -63,7 +63,7 @@ class HotseatWidthCalculationTest : FakeInvariantDeviceProfileTest() {
|
||||
val dp = newDP()
|
||||
dp.isTaskbarPresentInApps = true
|
||||
|
||||
assertThat(dp.hotseatBarEndOffset).isEqualTo(510)
|
||||
assertThat(dp.hotseatProfile.barEndOffset).isEqualTo(510)
|
||||
assertThat(dp.numShownHotseatIcons).isEqualTo(4)
|
||||
assertThat(dp.hotseatBorderSpace).isEqualTo(40)
|
||||
assertThat(dp.hotseatColumnSpan).isEqualTo(6)
|
||||
@@ -86,7 +86,7 @@ class HotseatWidthCalculationTest : FakeInvariantDeviceProfileTest() {
|
||||
val dp = newDP()
|
||||
dp.isTaskbarPresentInApps = true
|
||||
|
||||
assertThat(dp.hotseatBarEndOffset).isEqualTo(705)
|
||||
assertThat(dp.hotseatProfile.barEndOffset).isEqualTo(705)
|
||||
assertThat(dp.numShownHotseatIcons).isEqualTo(6)
|
||||
assertThat(dp.hotseatBorderSpace).isEqualTo(54)
|
||||
assertThat(dp.hotseatColumnSpan).isEqualTo(6)
|
||||
@@ -110,7 +110,7 @@ class HotseatWidthCalculationTest : FakeInvariantDeviceProfileTest() {
|
||||
val dp = newDP()
|
||||
dp.isTaskbarPresentInApps = true
|
||||
|
||||
assertThat(dp.hotseatBarEndOffset).isEqualTo(660)
|
||||
assertThat(dp.hotseatProfile.barEndOffset).isEqualTo(660)
|
||||
assertThat(dp.numShownHotseatIcons).isEqualTo(6)
|
||||
assertThat(dp.hotseatBorderSpace).isEqualTo(100)
|
||||
assertThat(dp.hotseatColumnSpan).isEqualTo(6)
|
||||
@@ -131,7 +131,7 @@ class HotseatWidthCalculationTest : FakeInvariantDeviceProfileTest() {
|
||||
val dp = newDP()
|
||||
dp.isTaskbarPresentInApps = true
|
||||
|
||||
assertThat(dp.hotseatBarEndOffset).isEqualTo(660)
|
||||
assertThat(dp.hotseatProfile.barEndOffset).isEqualTo(660)
|
||||
assertThat(dp.numShownHotseatIcons).isEqualTo(6)
|
||||
assertThat(dp.hotseatBorderSpace).isEqualTo(34)
|
||||
assertThat(dp.hotseatColumnSpan).isEqualTo(4)
|
||||
@@ -155,7 +155,7 @@ class HotseatWidthCalculationTest : FakeInvariantDeviceProfileTest() {
|
||||
val dp = newDP()
|
||||
dp.isTaskbarPresentInApps = true
|
||||
|
||||
assertThat(dp.hotseatBarEndOffset).isEqualTo(660)
|
||||
assertThat(dp.hotseatProfile.barEndOffset).isEqualTo(660)
|
||||
assertThat(dp.numShownHotseatIcons).isEqualTo(5)
|
||||
assertThat(dp.hotseatBorderSpace).isEqualTo(36)
|
||||
assertThat(dp.hotseatColumnSpan).isEqualTo(4)
|
||||
@@ -174,7 +174,7 @@ class HotseatWidthCalculationTest : FakeInvariantDeviceProfileTest() {
|
||||
val dp = newDP()
|
||||
dp.isTaskbarPresentInApps = true
|
||||
|
||||
assertThat(dp.hotseatBarEndOffset).isEqualTo(600)
|
||||
assertThat(dp.hotseatProfile.barEndOffset).isEqualTo(600)
|
||||
assertThat(dp.numShownHotseatIcons).isEqualTo(6)
|
||||
assertThat(dp.hotseatBorderSpace).isEqualTo(48)
|
||||
assertThat(dp.hotseatColumnSpan).isEqualTo(8)
|
||||
|
||||
+5
-14
@@ -22,10 +22,8 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.filters.SmallTest
|
||||
import com.android.launcher3.Flags
|
||||
import com.android.launcher3.LauncherSettings.Favorites
|
||||
import com.android.launcher3.util.LauncherModelHelper
|
||||
import com.android.launcher3.util.LauncherModelHelper.SandboxModelContext
|
||||
import com.android.launcher3.util.SandboxApplication
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
@@ -37,9 +35,8 @@ import org.junit.runner.RunWith
|
||||
class LauncherRestoreEventLoggerImplTest {
|
||||
|
||||
@get:Rule val setFlagsRule = SetFlagsRule()
|
||||
@get:Rule val mSandboxContext = SandboxApplication()
|
||||
|
||||
private val mLauncherModelHelper = LauncherModelHelper()
|
||||
private val mSandboxContext: SandboxModelContext = mLauncherModelHelper.sandboxContext
|
||||
private lateinit var loggerUnderTest: LauncherRestoreEventLoggerImpl
|
||||
|
||||
@Before
|
||||
@@ -47,12 +44,6 @@ class LauncherRestoreEventLoggerImplTest {
|
||||
loggerUnderTest = LauncherRestoreEventLoggerImpl(mSandboxContext)
|
||||
}
|
||||
|
||||
@After
|
||||
fun teardown() {
|
||||
loggerUnderTest.restoreEventLogger.clearData()
|
||||
mLauncherModelHelper.destroy()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `logLauncherItemsRestoreFailed logs multiple items as failing restore`() {
|
||||
// Given
|
||||
@@ -62,7 +53,7 @@ class LauncherRestoreEventLoggerImplTest {
|
||||
loggerUnderTest.logLauncherItemsRestoreFailed(
|
||||
dataType = expectedDataType,
|
||||
count = 5,
|
||||
error = expectedError
|
||||
error = expectedError,
|
||||
)
|
||||
// Then
|
||||
val actualResult = loggerUnderTest.restoreEventLogger.loggingResults.first()
|
||||
@@ -108,7 +99,7 @@ class LauncherRestoreEventLoggerImplTest {
|
||||
// When
|
||||
loggerUnderTest.logSingleFavoritesItemRestoreFailed(
|
||||
favoritesId = Favorites.ITEM_TYPE_APPWIDGET,
|
||||
error = expectedError
|
||||
error = expectedError,
|
||||
)
|
||||
// Then
|
||||
val actualResult = loggerUnderTest.restoreEventLogger.loggingResults.first()
|
||||
@@ -127,7 +118,7 @@ class LauncherRestoreEventLoggerImplTest {
|
||||
loggerUnderTest.logFavoritesItemsRestoreFailed(
|
||||
favoritesId = Favorites.ITEM_TYPE_DEEP_SHORTCUT,
|
||||
count = 5,
|
||||
error = expectedError
|
||||
error = expectedError,
|
||||
)
|
||||
// Then
|
||||
val actualResult = loggerUnderTest.restoreEventLogger.loggingResults.first()
|
||||
|
||||
+17
-14
@@ -29,8 +29,8 @@ import com.android.launcher3.R
|
||||
import com.android.launcher3.dagger.LauncherAppComponent
|
||||
import com.android.launcher3.dagger.LauncherAppModule
|
||||
import com.android.launcher3.dagger.LauncherAppSingleton
|
||||
import com.android.launcher3.util.LauncherModelHelper
|
||||
import com.android.launcher3.util.MSDLPlayerWrapper
|
||||
import com.android.launcher3.util.SandboxApplication
|
||||
import com.android.systemui.contextualeducation.GestureType
|
||||
import com.android.systemui.shared.system.InputConsumerController
|
||||
import dagger.BindsInstance
|
||||
@@ -39,8 +39,8 @@ import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Answers.RETURNS_DEEP_STUBS
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito.mock
|
||||
import org.mockito.Mockito.spy
|
||||
import org.mockito.junit.MockitoJUnit
|
||||
import org.mockito.kotlin.eq
|
||||
@@ -53,25 +53,28 @@ class LauncherSwipeHandlerV2Test {
|
||||
|
||||
@Mock private lateinit var taskAnimationManager: TaskAnimationManager
|
||||
|
||||
@Mock private lateinit var deviceState: RecentsAnimationDeviceState
|
||||
|
||||
private lateinit var gestureState: GestureState
|
||||
@Mock private lateinit var inputConsumerController: InputConsumerController
|
||||
|
||||
@Mock private lateinit var systemUiProxy: SystemUiProxy
|
||||
@Mock(answer = RETURNS_DEEP_STUBS) private lateinit var systemUiProxy: SystemUiProxy
|
||||
|
||||
@Mock(answer = RETURNS_DEEP_STUBS) private lateinit var recentsModel: RecentsModel
|
||||
|
||||
@Mock private lateinit var msdlPlayerWrapper: MSDLPlayerWrapper
|
||||
|
||||
@Mock private lateinit var rotationTouchHelper: RotationTouchHelper
|
||||
|
||||
private lateinit var underTest: LauncherSwipeHandlerV2
|
||||
|
||||
@get:Rule val mockitoRule = MockitoJUnit.rule()
|
||||
|
||||
private val launcherModelHelper = LauncherModelHelper()
|
||||
private val sandboxContext = launcherModelHelper.sandboxContext
|
||||
@get:Rule val sandboxContext = SandboxApplication()
|
||||
|
||||
private val flingSpeed =
|
||||
-(sandboxContext.resources.getDimension(R.dimen.quickstep_fling_threshold_speed) + 1)
|
||||
|
||||
private val displayManager: DisplayManager =
|
||||
sandboxContext.spyService(DisplayManager::class.java)
|
||||
private lateinit var displayManager: DisplayManager
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
@@ -82,14 +85,14 @@ class LauncherSwipeHandlerV2Test {
|
||||
DisplayInfo(),
|
||||
DEFAULT_DISPLAY_ADJUSTMENTS,
|
||||
)
|
||||
displayManager = sandboxContext.spyService(DisplayManager::class.java)
|
||||
whenever(displayManager.getDisplay(eq(DEFAULT_DISPLAY))).thenReturn(display)
|
||||
whenever(displayManager.displays).thenReturn(arrayOf(display))
|
||||
|
||||
sandboxContext.initDaggerComponent(
|
||||
DaggerTestComponent.builder()
|
||||
.bindSystemUiProxy(systemUiProxy)
|
||||
.bindRotationHelper(mock(RotationTouchHelper::class.java))
|
||||
.bindRecentsState(mock(RecentsAnimationDeviceState::class.java))
|
||||
.bindRecentsModel(recentsModel)
|
||||
)
|
||||
gestureState =
|
||||
spy(
|
||||
@@ -104,6 +107,8 @@ class LauncherSwipeHandlerV2Test {
|
||||
LauncherSwipeHandlerV2(
|
||||
sandboxContext,
|
||||
taskAnimationManager,
|
||||
deviceState,
|
||||
rotationTouchHelper,
|
||||
gestureState,
|
||||
0,
|
||||
false,
|
||||
@@ -134,11 +139,9 @@ class LauncherSwipeHandlerV2Test {
|
||||
interface TestComponent : LauncherAppComponent {
|
||||
@Component.Builder
|
||||
interface Builder : LauncherAppComponent.Builder {
|
||||
@BindsInstance fun bindSystemUiProxy(proxy: SystemUiProxy): Builder
|
||||
@BindsInstance fun bindSystemUiProxy(systemUiProxy: SystemUiProxy): Builder
|
||||
|
||||
@BindsInstance fun bindRotationHelper(helper: RotationTouchHelper): Builder
|
||||
|
||||
@BindsInstance fun bindRecentsState(state: RecentsAnimationDeviceState): Builder
|
||||
@BindsInstance fun bindRecentsModel(recentsModel: RecentsModel): Builder
|
||||
|
||||
override fun build(): TestComponent
|
||||
}
|
||||
|
||||
+8
@@ -76,6 +76,8 @@ public class LauncherSwipeHandlerV2TestCase extends AbsSwipeUpHandlerTestCase<
|
||||
return new LauncherSwipeHandlerV2(
|
||||
mContext,
|
||||
mTaskAnimationManager,
|
||||
mDeviceState,
|
||||
mRotationTouchHelper,
|
||||
mGestureState,
|
||||
touchTimeMs,
|
||||
continuingLastGesture,
|
||||
@@ -94,4 +96,10 @@ public class LauncherSwipeHandlerV2TestCase extends AbsSwipeUpHandlerTestCase<
|
||||
protected RecentsView<QuickstepLauncher, LauncherState> getRecentsView() {
|
||||
return mRecentsView;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected LauncherState getBaseState() {
|
||||
return LauncherState.NORMAL;
|
||||
}
|
||||
}
|
||||
+203
-29
@@ -16,20 +16,29 @@
|
||||
|
||||
package com.android.quickstep
|
||||
|
||||
import android.platform.test.flag.junit.SetFlagsRule
|
||||
import android.content.Intent
|
||||
import android.view.Display.DEFAULT_DISPLAY
|
||||
import androidx.test.filters.SmallTest
|
||||
import com.android.launcher3.Flags
|
||||
import com.android.app.displaylib.DisplayRepository
|
||||
import com.android.app.displaylib.fakes.FakePerDisplayRepository
|
||||
import com.android.app.displaylib.PerDisplayRepository
|
||||
import com.android.launcher3.LauncherState
|
||||
import com.android.launcher3.statemanager.StateManager
|
||||
import com.android.launcher3.statemanager.StatefulActivity
|
||||
import com.android.launcher3.uioverrides.QuickstepLauncher
|
||||
import com.android.launcher3.util.LauncherMultivalentJUnit
|
||||
import com.android.launcher3.util.RunnableList
|
||||
import com.android.launcher3.util.TestDispatcherProvider
|
||||
import com.android.launcher3.util.rule.setFlags
|
||||
import com.android.quickstep.OverviewCommandHelper.CommandInfo
|
||||
import com.android.quickstep.OverviewCommandHelper.CommandInfo.CommandStatus
|
||||
import com.android.quickstep.OverviewCommandHelper.CommandType
|
||||
import com.android.quickstep.fallback.window.RecentsDisplayModel
|
||||
import com.android.quickstep.OverviewCommandHelper.Companion.TOGGLE_PREVIOUS_TIMEOUT_MS
|
||||
import com.android.quickstep.views.RecentsView
|
||||
import com.android.quickstep.views.TaskView
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.coroutines.test.StandardTestDispatcher
|
||||
@@ -38,64 +47,80 @@ import kotlinx.coroutines.test.advanceTimeBy
|
||||
import kotlinx.coroutines.test.runCurrent
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Mockito.doAnswer
|
||||
import org.mockito.Mockito.spy
|
||||
import org.mockito.kotlin.any
|
||||
import org.mockito.kotlin.doNothing
|
||||
import org.mockito.kotlin.mock
|
||||
import org.mockito.kotlin.verify
|
||||
import org.mockito.kotlin.whenever
|
||||
|
||||
@SmallTest
|
||||
@RunWith(LauncherMultivalentJUnit::class)
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
class OverviewCommandHelperTest {
|
||||
@get:Rule val setFlagsRule: SetFlagsRule = SetFlagsRule()
|
||||
|
||||
private lateinit var sut: OverviewCommandHelper
|
||||
private val dispatcher = StandardTestDispatcher()
|
||||
private val testScope = TestScope(dispatcher)
|
||||
|
||||
private var pendingCallbacksWithDelays = mutableListOf<Long>()
|
||||
|
||||
private val recentsDisplayModel: RecentsDisplayModel = mock()
|
||||
private val defaultDisplayResource: RecentsDisplayModel.RecentsDisplayResource = mock()
|
||||
private val secondaryDisplayResource: RecentsDisplayModel.RecentsDisplayResource = mock()
|
||||
private val displayRepository: DisplayRepository = mock()
|
||||
private val executeCommandDisplayIds = mutableListOf<Int>()
|
||||
|
||||
private val recentView: RecentsView<*, *> = mock()
|
||||
private val stateManager: StateManager<LauncherState, StatefulActivity<LauncherState>> = mock()
|
||||
private val containerInterface: BaseActivityInterface<LauncherState, QuickstepLauncher> = mock()
|
||||
private val taskAnimationManager: TaskAnimationManager = mock()
|
||||
private val touchInteractionService: TouchInteractionService = mock()
|
||||
private var elapsedRealtime = 100L
|
||||
|
||||
private fun setupDefaultDisplay() {
|
||||
whenever(defaultDisplayResource.displayId).thenReturn(DEFAULT_DISPLAY)
|
||||
whenever(recentsDisplayModel.activeDisplayResources)
|
||||
.thenReturn(listOf(defaultDisplayResource))
|
||||
whenever(displayRepository.displayIds).thenReturn(MutableStateFlow(setOf(DEFAULT_DISPLAY)))
|
||||
}
|
||||
|
||||
private fun setupMultipleDisplays() {
|
||||
whenever(defaultDisplayResource.displayId).thenReturn(DEFAULT_DISPLAY)
|
||||
whenever(secondaryDisplayResource.displayId).thenReturn(1)
|
||||
whenever(recentsDisplayModel.activeDisplayResources)
|
||||
.thenReturn(listOf(defaultDisplayResource, secondaryDisplayResource))
|
||||
whenever(displayRepository.displayIds)
|
||||
.thenReturn(MutableStateFlow(setOf(DEFAULT_DISPLAY, 1)))
|
||||
}
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
@Before
|
||||
fun setup() {
|
||||
setFlagsRule.setFlags(true, Flags.FLAG_ENABLE_OVERVIEW_COMMAND_HELPER_TIMEOUT)
|
||||
|
||||
setupDefaultDisplay()
|
||||
|
||||
val overviewComponentObserver = mock<OverviewComponentObserver>()
|
||||
whenever(overviewComponentObserver.getContainerInterface(any()))
|
||||
.thenReturn(containerInterface)
|
||||
whenever(overviewComponentObserver.getHomeIntent(any())).thenReturn(mock<Intent>())
|
||||
whenever(recentView.getStateManager()).thenReturn(stateManager)
|
||||
whenever(containerInterface.switchToRecentsIfVisible(any())).thenReturn(true)
|
||||
whenever(taskAnimationManager.maybeStartHomeAction(any())).thenAnswer { invocation ->
|
||||
invocation.getArgument<Runnable>(0).run()
|
||||
}
|
||||
|
||||
sut =
|
||||
spy(
|
||||
OverviewCommandHelper(
|
||||
touchInteractionService = mock(),
|
||||
overviewComponentObserver = mock(),
|
||||
touchInteractionService = touchInteractionService,
|
||||
overviewComponentObserver = overviewComponentObserver,
|
||||
dispatcherProvider = TestDispatcherProvider(dispatcher),
|
||||
recentsDisplayModel = recentsDisplayModel,
|
||||
focusState = mock(),
|
||||
displayRepository = displayRepository,
|
||||
taskbarManager = mock(),
|
||||
taskAnimationManagerRepository =
|
||||
FakePerDisplayRepository<TaskAnimationManager> { _ -> taskAnimationManager },
|
||||
elapsedRealtime = ::elapsedRealtime,
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
private fun addCallbackDelay(delayInMillis: Long = 0) {
|
||||
pendingCallbacksWithDelays.add(delayInMillis)
|
||||
}
|
||||
|
||||
private fun mockExecuteCommand() {
|
||||
doAnswer { invocation ->
|
||||
val pendingCallback = invocation.arguments[1] as () -> Unit
|
||||
|
||||
@@ -116,13 +141,10 @@ class OverviewCommandHelperTest {
|
||||
.executeCommand(any<CommandInfo>(), any())
|
||||
}
|
||||
|
||||
private fun addCallbackDelay(delayInMillis: Long = 0) {
|
||||
pendingCallbacksWithDelays.add(delayInMillis)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun whenFirstCommandIsAdded_executeCommandImmediately() =
|
||||
testScope.runTest {
|
||||
mockExecuteCommand()
|
||||
// Add command to queue
|
||||
val commandInfo: CommandInfo = sut.addCommand(CommandType.HOME)!!
|
||||
assertThat(commandInfo.status).isEqualTo(CommandStatus.IDLE)
|
||||
@@ -133,6 +155,7 @@ class OverviewCommandHelperTest {
|
||||
@Test
|
||||
fun whenFirstCommandIsAdded_executeCommandImmediately_WithCallbackDelay() =
|
||||
testScope.runTest {
|
||||
mockExecuteCommand()
|
||||
addCallbackDelay(100)
|
||||
|
||||
// Add command to queue
|
||||
@@ -150,6 +173,7 @@ class OverviewCommandHelperTest {
|
||||
@Test
|
||||
fun whenFirstCommandIsPendingCallback_NextCommandWillWait() =
|
||||
testScope.runTest {
|
||||
mockExecuteCommand()
|
||||
// Add command to queue
|
||||
addCallbackDelay(100)
|
||||
val commandType1 = CommandType.HOME
|
||||
@@ -157,7 +181,7 @@ class OverviewCommandHelperTest {
|
||||
assertThat(commandInfo1.status).isEqualTo(CommandStatus.IDLE)
|
||||
|
||||
addCallbackDelay(100)
|
||||
val commandType2 = CommandType.SHOW
|
||||
val commandType2 = CommandType.SHOW_ALT_TAB
|
||||
val commandInfo2: CommandInfo = sut.addCommand(commandType2)!!
|
||||
assertThat(commandInfo2.status).isEqualTo(CommandStatus.IDLE)
|
||||
|
||||
@@ -176,6 +200,7 @@ class OverviewCommandHelperTest {
|
||||
@Test
|
||||
fun whenCommandTakesTooLong_TriggerTimeout_AndExecuteNextCommand() =
|
||||
testScope.runTest {
|
||||
mockExecuteCommand()
|
||||
// Add command to queue
|
||||
addCallbackDelay(QUEUE_TIMEOUT)
|
||||
val commandType1 = CommandType.HOME
|
||||
@@ -183,7 +208,7 @@ class OverviewCommandHelperTest {
|
||||
assertThat(commandInfo1.status).isEqualTo(CommandStatus.IDLE)
|
||||
|
||||
addCallbackDelay(100)
|
||||
val commandType2 = CommandType.SHOW
|
||||
val commandType2 = CommandType.SHOW_ALT_TAB
|
||||
val commandInfo2: CommandInfo = sut.addCommand(commandType2)!!
|
||||
assertThat(commandInfo2.status).isEqualTo(CommandStatus.IDLE)
|
||||
|
||||
@@ -202,6 +227,7 @@ class OverviewCommandHelperTest {
|
||||
@Test
|
||||
fun whenAllDisplaysCommandIsAdded_singleCommandProcessedForDefaultDisplay() =
|
||||
testScope.runTest {
|
||||
mockExecuteCommand()
|
||||
executeCommandDisplayIds.clear()
|
||||
// Add command to queue
|
||||
val commandInfo: CommandInfo = sut.addCommandsForAllDisplays(CommandType.HOME)!!
|
||||
@@ -214,6 +240,7 @@ class OverviewCommandHelperTest {
|
||||
@Test
|
||||
fun whenAllDisplaysCommandIsAdded_multipleCommandsProcessedForMultipleDisplays() =
|
||||
testScope.runTest {
|
||||
mockExecuteCommand()
|
||||
setupMultipleDisplays()
|
||||
executeCommandDisplayIds.clear()
|
||||
// Add command to queue
|
||||
@@ -228,6 +255,7 @@ class OverviewCommandHelperTest {
|
||||
@Test
|
||||
fun whenAllExceptDisplayCommandIsAdded_otherDisplayProcessed() =
|
||||
testScope.runTest {
|
||||
mockExecuteCommand()
|
||||
setupMultipleDisplays()
|
||||
executeCommandDisplayIds.clear()
|
||||
// Add command to queue
|
||||
@@ -242,6 +270,7 @@ class OverviewCommandHelperTest {
|
||||
@Test
|
||||
fun whenSingleDisplayCommandIsAdded_thatDisplayIsProcessed() =
|
||||
testScope.runTest {
|
||||
mockExecuteCommand()
|
||||
executeCommandDisplayIds.clear()
|
||||
val displayId = 5
|
||||
// Add command to queue
|
||||
@@ -252,6 +281,151 @@ class OverviewCommandHelperTest {
|
||||
assertThat(executeCommandDisplayIds).containsExactly(displayId)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun recentViewNotVisible_toggleOverviewPrev_goToOverview() =
|
||||
testScope.runTest {
|
||||
whenever(containerInterface.getVisibleRecentsView<RecentsView<*, *>>()).thenReturn(null)
|
||||
sut.addCommand(CommandType.TOGGLE_OVERVIEW_PREVIOUS)!!
|
||||
runCurrent()
|
||||
verify(containerInterface).switchToRecentsIfVisible(any())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun recentViewVisible_toggleOverviewPrev_goToHome() =
|
||||
testScope.runTest {
|
||||
whenever(containerInterface.getVisibleRecentsView<RecentsView<*, *>>())
|
||||
.thenReturn(recentView)
|
||||
sut.addCommand(CommandType.TOGGLE_OVERVIEW_PREVIOUS)!!
|
||||
runCurrent()
|
||||
verify(recentView).startHome()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun recentViewVisible_hasRunningTask_toggleOverviewPrev_goToPrevTask() =
|
||||
testScope.runTest {
|
||||
whenever(containerInterface.getVisibleRecentsView<RecentsView<*, *>>())
|
||||
.thenReturn(recentView)
|
||||
val mockTask = mock<TaskView>()
|
||||
whenever(recentView.runningTaskView).thenReturn(mockTask)
|
||||
|
||||
sut.addCommand(CommandType.TOGGLE_OVERVIEW_PREVIOUS)!!
|
||||
runCurrent()
|
||||
|
||||
verify(mockTask).launchWithAnimation()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun recentViewVisible_hasRunningTask_toggle() =
|
||||
testScope.runTest {
|
||||
val callbackList = RunnableList()
|
||||
|
||||
fun getMockTask(vararg elements: Int) =
|
||||
mock<TaskView>().apply {
|
||||
whenever(taskIdSet).thenReturn(elements.toSet())
|
||||
whenever(recentView.getTaskViewByTaskIds(elements)).thenReturn(this)
|
||||
whenever(launchWithAnimation()).thenReturn(callbackList)
|
||||
}
|
||||
val mockTask1 = getMockTask(1, 2, 3)
|
||||
val mockTask2 = getMockTask(4, 5)
|
||||
val mockTask3 = getMockTask(6, 7)
|
||||
|
||||
// TOGGLE with a runningTaskView should go to nextTaskView
|
||||
whenever(containerInterface.getVisibleRecentsView<RecentsView<*, *>>())
|
||||
.thenReturn(recentView)
|
||||
whenever(recentView.runningTaskView).thenReturn(mockTask1)
|
||||
whenever(recentView.nextTaskView).thenReturn(mockTask2)
|
||||
sut.addCommand(CommandType.TOGGLE)
|
||||
runCurrent()
|
||||
verify(mockTask2).launchWithAnimation()
|
||||
callbackList.executeAllAndDestroy()
|
||||
|
||||
// Next TOGGLE with runningTaskView will return to previous runningTaskView
|
||||
whenever(recentView.runningTaskView).thenReturn(mockTask2)
|
||||
whenever(recentView.nextTaskView).thenReturn(mockTask3)
|
||||
sut.addCommand(CommandType.TOGGLE)
|
||||
runCurrent()
|
||||
verify(mockTask1).launchWithAnimation()
|
||||
callbackList.executeAllAndDestroy()
|
||||
|
||||
// After TOGGLE_PREVIOUS_TIMEOUT_MS has passed, subsequent TOGGLE will go to
|
||||
// nextTaskView again.
|
||||
whenever(recentView.runningTaskView).thenReturn(mockTask1)
|
||||
whenever(recentView.nextTaskView).thenReturn(mockTask3)
|
||||
sut.addCommand(CommandType.TOGGLE)
|
||||
elapsedRealtime += TOGGLE_PREVIOUS_TIMEOUT_MS
|
||||
runCurrent()
|
||||
verify(mockTask3).launchWithAnimation()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun recentViewVisible_noRunningTask_toggle_goToFirstNonDesktopTaskView() =
|
||||
testScope.runTest {
|
||||
val firstNonDesktopTaskView = mock<TaskView>()
|
||||
val lastDesktopTaskView = mock<TaskView>()
|
||||
val previousTaskView = mock<TaskView>()
|
||||
val nextTaskView = mock<TaskView>()
|
||||
|
||||
whenever(containerInterface.getVisibleRecentsView<RecentsView<*, *>>())
|
||||
.thenReturn(recentView)
|
||||
whenever(recentView.runningTaskView).thenReturn(null)
|
||||
whenever(recentView.firstNonDesktopTaskView).thenReturn(firstNonDesktopTaskView)
|
||||
whenever(recentView.lastDesktopTaskView).thenReturn(lastDesktopTaskView)
|
||||
whenever(recentView.previousTaskView).thenReturn(previousTaskView)
|
||||
whenever(recentView.nextTaskView).thenReturn(nextTaskView)
|
||||
sut.addCommand(CommandType.TOGGLE)
|
||||
runCurrent()
|
||||
verify(firstNonDesktopTaskView).launchWithAnimation()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun recentViewVisible_noRunningTask_toggle_goToLastDesktopTaskView() =
|
||||
testScope.runTest {
|
||||
val firstNonDesktopTaskView = mock<TaskView>()
|
||||
val lastDesktopTaskView = mock<TaskView>()
|
||||
val firstTaskView = mock<TaskView>()
|
||||
val previousTaskView = mock<TaskView>()
|
||||
val nextTaskView = mock<TaskView>()
|
||||
|
||||
whenever(containerInterface.getVisibleRecentsView<RecentsView<*, *>>())
|
||||
.thenReturn(recentView)
|
||||
whenever(recentView.runningTaskView).thenReturn(null)
|
||||
whenever(recentView.firstNonDesktopTaskView).thenReturn(null)
|
||||
whenever(recentView.lastDesktopTaskView).thenReturn(lastDesktopTaskView)
|
||||
whenever(recentView.firstTaskView).thenReturn(firstTaskView)
|
||||
whenever(recentView.previousTaskView).thenReturn(previousTaskView)
|
||||
whenever(recentView.nextTaskView).thenReturn(nextTaskView)
|
||||
sut.addCommand(CommandType.TOGGLE)
|
||||
runCurrent()
|
||||
verify(lastDesktopTaskView).launchWithAnimation()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun recentViewVisible_hasRunningTask_toggle_goToPreviousTaskView() =
|
||||
testScope.runTest {
|
||||
val runningTaskView = mock<TaskView>()
|
||||
val firstTaskView = mock<TaskView>()
|
||||
val previousTaskView = mock<TaskView>()
|
||||
|
||||
whenever(containerInterface.getVisibleRecentsView<RecentsView<*, *>>())
|
||||
.thenReturn(recentView)
|
||||
whenever(recentView.runningTaskView).thenReturn(runningTaskView)
|
||||
whenever(recentView.firstTaskView).thenReturn(firstTaskView)
|
||||
whenever(recentView.previousTaskView).thenReturn(previousTaskView)
|
||||
whenever(recentView.nextTaskView).thenReturn(null)
|
||||
sut.addCommand(CommandType.TOGGLE)
|
||||
runCurrent()
|
||||
verify(previousTaskView).launchWithAnimation()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun whenHomeCommandIsAdded_executeHomeAction() =
|
||||
testScope.runTest {
|
||||
sut.addCommand(CommandType.HOME)
|
||||
runCurrent()
|
||||
verify(taskAnimationManager).maybeStartHomeAction(any())
|
||||
verify(touchInteractionService).startActivity(any())
|
||||
}
|
||||
|
||||
private companion object {
|
||||
const val QUEUE_TIMEOUT = 5001L
|
||||
const val EXTERNAL_DISPLAY_ID = 1
|
||||
|
||||
+8
-43
@@ -18,8 +18,7 @@ package com.android.quickstep;
|
||||
|
||||
import static android.view.Display.DEFAULT_DISPLAY;
|
||||
|
||||
import static com.android.launcher3.Flags.FLAG_ENABLE_SEPARATE_EXTERNAL_DISPLAY_TASKS;
|
||||
import static com.android.window.flags.Flags.FLAG_ENABLE_MULTIPLE_DESKTOPS_BACKEND;
|
||||
import static com.android.window.flags2.Flags.FLAG_ENABLE_MULTIPLE_DESKTOPS_BACKEND;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
@@ -49,8 +48,8 @@ import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
import com.android.internal.R;
|
||||
import com.android.launcher3.statehandlers.DesktopVisibilityController;
|
||||
import com.android.launcher3.util.DaggerSingletonTracker;
|
||||
import com.android.launcher3.util.Executors;
|
||||
import com.android.launcher3.util.LooperExecutor;
|
||||
import com.android.quickstep.util.DesktopTask;
|
||||
import com.android.quickstep.util.GroupTask;
|
||||
@@ -95,7 +94,7 @@ public class RecentTasksListTest {
|
||||
@Before
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
LooperExecutor mockMainThreadExecutor = mock(LooperExecutor.class);
|
||||
LooperExecutor mainThreadExecutor = Executors.MAIN_EXECUTOR;
|
||||
KeyguardManager mockKeyguardManager = mock(KeyguardManager.class);
|
||||
|
||||
// Set desktop mode supported
|
||||
@@ -104,9 +103,8 @@ public class RecentTasksListTest {
|
||||
when(mResources.getBoolean(R.bool.config_canInternalDisplayHostDesktops))
|
||||
.thenReturn(true);
|
||||
|
||||
mRecentTasksList = new RecentTasksList(mContext, mockMainThreadExecutor,
|
||||
mRecentTasksList = new RecentTasksList(mContext, mainThreadExecutor,
|
||||
mockKeyguardManager, mSystemUiProxy, mTopTaskTracker,
|
||||
mock(DesktopVisibilityController.class),
|
||||
mock(DaggerSingletonTracker.class));
|
||||
}
|
||||
|
||||
@@ -123,8 +121,8 @@ public class RecentTasksListTest {
|
||||
new RecentTaskInfo(), new RecentTaskInfo(), new SplitBounds(
|
||||
/* leftTopBounds = */ new Rect(),
|
||||
/* rightBottomBounds = */ new Rect(),
|
||||
/* leftTopTaskId = */ -1,
|
||||
/* rightBottomTaskId = */ -1,
|
||||
/* leftTopTaskId = */ 1,
|
||||
/* rightBottomTaskId = */ 2,
|
||||
/* snapPosition = */ SplitScreenConstants.SNAP_TO_2_50_50));
|
||||
when(mSystemUiProxy.getRecentTasks(anyInt(), anyInt()))
|
||||
.thenReturn(new ArrayList<>(Collections.singletonList(recentTaskInfos)));
|
||||
@@ -219,8 +217,8 @@ public class RecentTasksListTest {
|
||||
new SplitBounds(
|
||||
/* leftTopBounds = */ new Rect(),
|
||||
/* rightBottomBounds = */ new Rect(),
|
||||
/* leftTopTaskId = */ -1,
|
||||
/* rightBottomTaskId = */ -1,
|
||||
/* leftTopTaskId = */ 1,
|
||||
/* rightBottomTaskId = */ 2,
|
||||
/* snapPosition = */ SplitScreenConstants.SNAP_TO_2_50_50));
|
||||
when(mSystemUiProxy.getRecentTasks(anyInt(), anyInt()))
|
||||
.thenReturn(new ArrayList<>(Collections.singletonList(recentTaskInfos)));
|
||||
@@ -236,39 +234,6 @@ public class RecentTasksListTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags({FLAG_ENABLE_SEPARATE_EXTERNAL_DISPLAY_TASKS,
|
||||
FLAG_ENABLE_MULTIPLE_DESKTOPS_BACKEND})
|
||||
public void loadTasksInBackground_freeformTask_createsDesktopTask() throws Exception {
|
||||
List<TaskInfo> tasks = Arrays.asList(
|
||||
createRecentTaskInfo(1 /* taskId */, DEFAULT_DISPLAY),
|
||||
createRecentTaskInfo(4 /* taskId */, DEFAULT_DISPLAY),
|
||||
createRecentTaskInfo(5 /* taskId */, 1 /* displayId */),
|
||||
createRecentTaskInfo(6 /* taskId */, 1 /* displayId */));
|
||||
GroupedTaskInfo recentTaskInfos = GroupedTaskInfo.forDeskTasks(
|
||||
0 /* deskId */, DEFAULT_DISPLAY, tasks,
|
||||
Collections.emptySet() /* minimizedTaskIds */);
|
||||
when(mSystemUiProxy.getRecentTasks(anyInt(), anyInt()))
|
||||
.thenReturn(new ArrayList<>(Collections.singletonList(recentTaskInfos)));
|
||||
|
||||
List<GroupTask> taskList = mRecentTasksList.loadTasksInBackground(
|
||||
Integer.MAX_VALUE /* numTasks */, -1 /* requestId */, false /* loadKeysOnly */);
|
||||
|
||||
assertEquals(1, taskList.size());
|
||||
assertEquals(TaskViewType.DESKTOP, taskList.get(0).taskViewType);
|
||||
List<Task> actualFreeformTasks = taskList.get(0).getTasks();
|
||||
assertEquals(4, actualFreeformTasks.size());
|
||||
assertEquals(1, actualFreeformTasks.get(0).key.id);
|
||||
assertFalse(actualFreeformTasks.get(0).isMinimized);
|
||||
assertEquals(4, actualFreeformTasks.get(1).key.id);
|
||||
assertFalse(actualFreeformTasks.get(1).isMinimized);
|
||||
assertEquals(5, actualFreeformTasks.get(2).key.id);
|
||||
assertFalse(actualFreeformTasks.get(2).isMinimized);
|
||||
assertEquals(6, actualFreeformTasks.get(3).key.id);
|
||||
assertFalse(actualFreeformTasks.get(3).isMinimized);
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(FLAG_ENABLE_SEPARATE_EXTERNAL_DISPLAY_TASKS)
|
||||
@DisableFlags(FLAG_ENABLE_MULTIPLE_DESKTOPS_BACKEND)
|
||||
public void loadTasksInBackground_freeformTask_createsDesktopTaskPerDisplay() throws Exception {
|
||||
List<TaskInfo> tasks = Arrays.asList(
|
||||
|
||||
+17
-33
@@ -1,6 +1,6 @@
|
||||
package com.android.quickstep
|
||||
|
||||
import android.view.Display
|
||||
import android.view.Display.DEFAULT_DISPLAY
|
||||
import androidx.test.annotation.UiThreadTest
|
||||
import androidx.test.filters.SmallTest
|
||||
import com.android.launcher3.dagger.LauncherComponentProvider
|
||||
@@ -14,9 +14,9 @@ import com.android.launcher3.util.LauncherMultivalentJUnit
|
||||
import com.android.launcher3.util.NavigationMode
|
||||
import com.android.launcher3.util.SandboxApplication
|
||||
import com.android.quickstep.util.GestureExclusionManager
|
||||
import com.android.systemui.shared.system.QuickStepContract
|
||||
import com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_ALLOW_GESTURE_IGNORING_BAR_VISIBILITY
|
||||
import com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_DEVICE_DREAMING
|
||||
import com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_DISABLE_GESTURE_PIP_ANIMATING
|
||||
import com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_DISABLE_GESTURE_SPLIT_INVOCATION
|
||||
import com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_HOME_DISABLED
|
||||
import com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_MAGNIFICATION_OVERLAP
|
||||
@@ -50,6 +50,7 @@ class RecentsAnimationDeviceStateTest {
|
||||
|
||||
@Mock private lateinit var exclusionManager: GestureExclusionManager
|
||||
@Mock private lateinit var info: Info
|
||||
@Mock private lateinit var rotationTouchHelper: RotationTouchHelper
|
||||
|
||||
private lateinit var underTest: RecentsAnimationDeviceState
|
||||
|
||||
@@ -61,10 +62,11 @@ class RecentsAnimationDeviceStateTest {
|
||||
underTest =
|
||||
RecentsAnimationDeviceState(
|
||||
context,
|
||||
DEFAULT_DISPLAY,
|
||||
rotationTouchHelper,
|
||||
exclusionManager,
|
||||
component.displayController,
|
||||
component.contextualSearchStateManager,
|
||||
component.rotationTouchHelper,
|
||||
component.settingsCache,
|
||||
component.daggerSingletonTracker,
|
||||
)
|
||||
@@ -152,7 +154,7 @@ class RecentsAnimationDeviceStateTest {
|
||||
|
||||
allSysUiStates().forEach { state ->
|
||||
val canStartGesture = !disablingStates.contains(state)
|
||||
underTest.setSysUIStateFlagsForDisplay(state, Display.DEFAULT_DISPLAY)
|
||||
underTest.setSysUIStateFlags(state)
|
||||
assertThat(underTest.canStartTrackpadGesture()).isEqualTo(canStartGesture)
|
||||
}
|
||||
}
|
||||
@@ -168,7 +170,7 @@ class RecentsAnimationDeviceStateTest {
|
||||
)
|
||||
|
||||
stateToExpectedResult.forEach { (state, allowed) ->
|
||||
underTest.setSysUIStateFlagsForDisplay(state, Display.DEFAULT_DISPLAY)
|
||||
underTest.setSysUIStateFlags(state)
|
||||
assertThat(underTest.canStartTrackpadGesture()).isEqualTo(allowed)
|
||||
}
|
||||
}
|
||||
@@ -179,7 +181,7 @@ class RecentsAnimationDeviceStateTest {
|
||||
|
||||
allSysUiStates().forEach { state ->
|
||||
val canStartGesture = !disablingStates.contains(state)
|
||||
underTest.setSysUIStateFlagsForDisplay(state, Display.DEFAULT_DISPLAY)
|
||||
underTest.setSysUIStateFlags(state)
|
||||
assertThat(underTest.canStartSystemGesture()).isEqualTo(canStartGesture)
|
||||
}
|
||||
}
|
||||
@@ -199,40 +201,21 @@ class RecentsAnimationDeviceStateTest {
|
||||
)
|
||||
|
||||
stateToExpectedResult.forEach { (state, gestureAllowed) ->
|
||||
underTest.setSysUIStateFlagsForDisplay(state, Display.DEFAULT_DISPLAY)
|
||||
underTest.setSysUIStateFlags(state)
|
||||
assertThat(underTest.canStartSystemGesture()).isEqualTo(gestureAllowed)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getSystemUiStateFlags_defaultAwake() {
|
||||
val NOT_EXISTENT_DISPLAY = 2
|
||||
assertThat(underTest.getSystemUiStateFlags(NOT_EXISTENT_DISPLAY))
|
||||
.isEqualTo(QuickStepContract.SYSUI_STATE_AWAKE)
|
||||
}
|
||||
fun startOverviewCommandForDisallowedSysUiState() {
|
||||
val disallowedStates = GESTURE_DISABLING_SYSUI_STATES + SYSUI_STATE_OVERVIEW_DISABLED
|
||||
|
||||
@Test
|
||||
fun clearSysUIStateFlagsForDisplay_displayNotReturnedAnymore() {
|
||||
underTest.setSysUIStateFlagsForDisplay(1, /* displayId= */ 1)
|
||||
allSysUiStates().forEach { state ->
|
||||
underTest.setSysUIStateFlags(state)
|
||||
|
||||
assertThat(underTest.displaysWithSysUIState).contains(1)
|
||||
assertThat(underTest.getSystemUiStateFlags(1)).isEqualTo(1)
|
||||
|
||||
underTest.clearSysUIStateFlagsForDisplay(1)
|
||||
|
||||
assertThat(underTest.displaysWithSysUIState).doesNotContain(1)
|
||||
assertThat(underTest.getSystemUiStateFlags(1))
|
||||
.isEqualTo(QuickStepContract.SYSUI_STATE_AWAKE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun setSysUIStateFlagsForDisplay_setsCorrectly() {
|
||||
underTest.setSysUIStateFlagsForDisplay(1, /* displayId= */ 1)
|
||||
underTest.setSysUIStateFlagsForDisplay(2, /* displayId= */ 2)
|
||||
|
||||
assertThat(underTest.getSystemUiStateFlags(1)).isEqualTo(1)
|
||||
assertThat(underTest.getSystemUiStateFlags(2)).isEqualTo(2)
|
||||
assertThat(underTest.displaysWithSysUIState).containsAtLeast(1, 2)
|
||||
val isAllowed = !disallowedStates.contains(state)
|
||||
assertThat(underTest.canStartOverviewCommand()).isEqualTo(isAllowed)
|
||||
}
|
||||
}
|
||||
|
||||
private fun allSysUiStates(): List<Long> {
|
||||
@@ -249,6 +232,7 @@ class RecentsAnimationDeviceStateTest {
|
||||
SYSUI_STATE_MAGNIFICATION_OVERLAP,
|
||||
SYSUI_STATE_DEVICE_DREAMING,
|
||||
SYSUI_STATE_DISABLE_GESTURE_SPLIT_INVOCATION,
|
||||
SYSUI_STATE_DISABLE_GESTURE_PIP_ANIMATING,
|
||||
)
|
||||
private const val SYSUI_STATES_COUNT = 33
|
||||
private const val DEFAULT_STATE = 0L
|
||||
|
||||
@@ -45,11 +45,11 @@ import com.android.launcher3.graphics.ThemeManager;
|
||||
import com.android.launcher3.icons.IconProvider;
|
||||
import com.android.launcher3.util.DaggerSingletonTracker;
|
||||
import com.android.launcher3.util.LockedUserState;
|
||||
import com.android.launcher3.util.SplitConfigurationOptions;
|
||||
import com.android.quickstep.util.GroupTask;
|
||||
import com.android.quickstep.util.SplitTask;
|
||||
import com.android.systemui.shared.recents.model.Task;
|
||||
import com.android.systemui.shared.system.TaskStackChangeListeners;
|
||||
import com.android.wm.shell.shared.split.SplitBounds;
|
||||
import com.android.wm.shell.shared.split.SplitScreenConstants;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -74,6 +74,7 @@ public class RecentsModelTest {
|
||||
|
||||
@Mock
|
||||
private RecentTasksList mTasksList;
|
||||
private RecentsModel.RecentTasksChangedListener mRegisteredTaskListListener = null;
|
||||
|
||||
@Mock
|
||||
private HighResLoadingState mHighResLoadingState;
|
||||
@@ -103,6 +104,20 @@ public class RecentsModelTest {
|
||||
callback.accept(mTaskResult);
|
||||
return null;
|
||||
}).when(mTasksList).getTaskKeys(anyInt(), any());
|
||||
doAnswer(invocation -> {
|
||||
mRegisteredTaskListListener = invocation.getArgument(0);
|
||||
return null;
|
||||
}).when(mTasksList).registerRecentTasksChangedListener(any());
|
||||
doAnswer(invocation -> {
|
||||
mRegisteredTaskListListener = null;
|
||||
return null;
|
||||
}).when(mTasksList).unregisterRecentTasksChangedListener();
|
||||
doAnswer(invocation -> {
|
||||
if (mRegisteredTaskListListener != null) {
|
||||
mRegisteredTaskListListener.onRecentTasksChanged();
|
||||
}
|
||||
return null;
|
||||
}).when(mTasksList).onRecentTasksChanged();
|
||||
|
||||
when(mHighResLoadingState.isEnabled()).thenReturn(true);
|
||||
when(mThumbnailCache.getHighResLoadingState()).thenReturn(mHighResLoadingState);
|
||||
@@ -186,6 +201,38 @@ public class RecentsModelTest {
|
||||
verify(mThemeManager, times(1)).addChangeListener(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void recentTaskListChangesNotiftListeners() {
|
||||
RecentsModel.RecentTasksChangedListener listener1 = mock(
|
||||
RecentsModel.RecentTasksChangedListener.class);
|
||||
RecentsModel.RecentTasksChangedListener listener2 = mock(
|
||||
RecentsModel.RecentTasksChangedListener.class);
|
||||
|
||||
mRecentsModel.registerRecentTasksChangedListener(listener1);
|
||||
|
||||
mTasksList.onRecentTasksChanged();
|
||||
verify(listener1, times(1)).onRecentTasksChanged();
|
||||
verify(listener2, times(0)).onRecentTasksChanged();
|
||||
|
||||
mRecentsModel.registerRecentTasksChangedListener(listener2);
|
||||
|
||||
mTasksList.onRecentTasksChanged();
|
||||
verify(listener1, times(2)).onRecentTasksChanged();
|
||||
verify(listener2, times(1)).onRecentTasksChanged();
|
||||
|
||||
mRecentsModel.unregisterRecentTasksChangedListener(listener1);
|
||||
|
||||
mTasksList.onRecentTasksChanged();
|
||||
verify(listener1, times(2)).onRecentTasksChanged();
|
||||
verify(listener2, times(2)).onRecentTasksChanged();
|
||||
|
||||
mRecentsModel.unregisterRecentTasksChangedListener(listener2);
|
||||
|
||||
mTasksList.onRecentTasksChanged();
|
||||
verify(listener1, times(2)).onRecentTasksChanged();
|
||||
verify(listener2, times(2)).onRecentTasksChanged();
|
||||
}
|
||||
|
||||
private RecentTasksList.TaskLoadResult getTaskResult() {
|
||||
RecentTasksList.TaskLoadResult allTasks = new RecentTasksList.TaskLoadResult(0, false, 1);
|
||||
ActivityManager.RecentTaskInfo taskInfo1 = new ActivityManager.RecentTaskInfo();
|
||||
@@ -197,11 +244,11 @@ public class RecentsModelTest {
|
||||
Task task2 = Task.from(taskKey2, taskInfo2, false);
|
||||
|
||||
allTasks.add(
|
||||
new SplitTask(task1, task2, new SplitConfigurationOptions.SplitBounds(
|
||||
new SplitTask(task1, task2, new SplitBounds(
|
||||
/* leftTopBounds = */ new Rect(),
|
||||
/* rightBottomBounds = */ new Rect(),
|
||||
/* leftTopTaskId = */ -1,
|
||||
/* rightBottomTaskId = */ -1,
|
||||
/* leftTopTaskId = */ 1,
|
||||
/* rightBottomTaskId = */ 2,
|
||||
/* snapPosition = */ SplitScreenConstants.SNAP_TO_2_50_50)));
|
||||
return allTasks;
|
||||
}
|
||||
|
||||
+8
-25
@@ -19,21 +19,12 @@ package com.android.quickstep;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
import com.android.launcher3.dagger.LauncherAppComponent;
|
||||
import com.android.launcher3.dagger.LauncherAppSingleton;
|
||||
import com.android.launcher3.util.AllModulesForTest;
|
||||
import com.android.launcher3.util.LauncherMultivalentJUnit;
|
||||
import com.android.quickstep.fallback.FallbackRecentsView;
|
||||
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;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
|
||||
@@ -46,16 +37,9 @@ public class RecentsWindowSwipeHandlerTestCase extends AbsSwipeUpHandlerTestCase
|
||||
RecentsWindowSwipeHandler,
|
||||
FallbackWindowInterface> {
|
||||
|
||||
@Mock private RecentsDisplayModel mRecentsDisplayModel;
|
||||
@Mock private FallbackRecentsView<RecentsWindowManager> mRecentsView;
|
||||
@Mock private RecentsWindowManager mRecentsWindowManager;
|
||||
|
||||
@Before
|
||||
public void setRecentsDisplayModel() {
|
||||
mContext.initDaggerComponent(DaggerRecentsWindowSwipeHandlerTestCase_TestComponent.builder()
|
||||
.bindRecentsDisplayModel(mRecentsDisplayModel));
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected RecentsWindowSwipeHandler createSwipeHandler(long touchTimeMs,
|
||||
@@ -63,6 +47,9 @@ public class RecentsWindowSwipeHandlerTestCase extends AbsSwipeUpHandlerTestCase
|
||||
return new RecentsWindowSwipeHandler(
|
||||
mContext,
|
||||
mTaskAnimationManager,
|
||||
mDeviceState,
|
||||
mRotationTouchHelper,
|
||||
mRecentsWindowManager,
|
||||
mGestureState,
|
||||
touchTimeMs,
|
||||
continuingLastGesture,
|
||||
@@ -72,7 +59,7 @@ public class RecentsWindowSwipeHandlerTestCase extends AbsSwipeUpHandlerTestCase
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected RecentsViewContainer getRecentsContainer() {
|
||||
protected RecentsWindowManager getRecentsContainer() {
|
||||
return mRecentsWindowManager;
|
||||
}
|
||||
|
||||
@@ -82,13 +69,9 @@ public class RecentsWindowSwipeHandlerTestCase extends AbsSwipeUpHandlerTestCase
|
||||
return mRecentsView;
|
||||
}
|
||||
|
||||
@LauncherAppSingleton
|
||||
@Component(modules = {AllModulesForTest.class})
|
||||
interface TestComponent extends LauncherAppComponent {
|
||||
@Component.Builder
|
||||
interface Builder extends LauncherAppComponent.Builder {
|
||||
@BindsInstance Builder bindRecentsDisplayModel(RecentsDisplayModel model);
|
||||
@Override LauncherAppComponent build();
|
||||
}
|
||||
@NonNull
|
||||
@Override
|
||||
protected RecentsState getBaseState() {
|
||||
return RecentsState.BG_LAUNCHER;
|
||||
}
|
||||
}
|
||||
+103
-8
@@ -16,12 +16,18 @@
|
||||
|
||||
package com.android.quickstep;
|
||||
|
||||
import static com.android.quickstep.TaskAnimationManager.RECENTS_ANIMATION_START_TIMEOUT_MS;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@@ -32,6 +38,10 @@ import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Bundle;
|
||||
import android.os.SystemClock;
|
||||
import android.platform.test.annotations.DisableFlags;
|
||||
import android.platform.test.annotations.EnableFlags;
|
||||
import android.platform.test.flag.junit.SetFlagsRule;
|
||||
import android.view.Display;
|
||||
import android.view.RemoteAnimationTarget;
|
||||
import android.view.SurfaceControl;
|
||||
@@ -42,8 +52,10 @@ import androidx.test.filters.SmallTest;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
|
||||
import com.android.systemui.shared.system.RecentsAnimationControllerCompat;
|
||||
import com.android.window.flags2.Flags;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
@@ -53,7 +65,7 @@ import org.mockito.MockitoAnnotations;
|
||||
@SmallTest
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class TaskAnimationManagerTest {
|
||||
|
||||
private static final int EXTERNAL_DISPLAY_ID = 1;
|
||||
protected final Context mContext =
|
||||
InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
|
||||
@@ -61,17 +73,27 @@ public class TaskAnimationManagerTest {
|
||||
private SystemUiProxy mSystemUiProxy;
|
||||
|
||||
private TaskAnimationManager mTaskAnimationManager;
|
||||
private TaskAnimationManager mTaskAnimationManagerWithExternalDisplay;
|
||||
|
||||
@Rule
|
||||
public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mTaskAnimationManager = new TaskAnimationManager(mContext,
|
||||
RecentsAnimationDeviceState.INSTANCE.get(mContext), Display.DEFAULT_DISPLAY) {
|
||||
mTaskAnimationManager = new TaskAnimationManager(mContext, Display.DEFAULT_DISPLAY) {
|
||||
@Override
|
||||
SystemUiProxy getSystemUiProxy() {
|
||||
return mSystemUiProxy;
|
||||
}
|
||||
};
|
||||
mTaskAnimationManagerWithExternalDisplay =
|
||||
new TaskAnimationManager(mContext, EXTERNAL_DISPLAY_ID) {
|
||||
@Override
|
||||
SystemUiProxy getSystemUiProxy() {
|
||||
return mSystemUiProxy;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -86,14 +108,15 @@ public class TaskAnimationManagerTest {
|
||||
final ArgumentCaptor<ActivityOptions> optionsCaptor =
|
||||
ArgumentCaptor.forClass(ActivityOptions.class);
|
||||
verify(mSystemUiProxy)
|
||||
.startRecentsActivity(any(), optionsCaptor.capture(), any(), anyBoolean());
|
||||
.startRecentsActivity(any(), optionsCaptor.capture(), any(), anyBoolean(),
|
||||
any(), anyInt());
|
||||
assertEquals(ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOW_ALWAYS,
|
||||
optionsCaptor.getValue().getPendingIntentBackgroundActivityStartMode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLauncherDestroyed_whileRecentsAnimationStartPending_finishesAnimation() {
|
||||
final GestureState gestureState = mock(GestureState.class);
|
||||
final GestureState gestureState = buildMockGestureState();
|
||||
final ArgumentCaptor<RecentsAnimationCallbacks> listenerCaptor =
|
||||
ArgumentCaptor.forClass(RecentsAnimationCallbacks.class);
|
||||
final RecentsAnimationControllerCompat controllerCompat =
|
||||
@@ -116,17 +139,20 @@ public class TaskAnimationManagerTest {
|
||||
/* taskInfo= */ new ActivityManager.RunningTaskInfo(),
|
||||
/* allowEnterPip= */ false);
|
||||
|
||||
doReturn(mock(LauncherActivityInterface.class)).when(gestureState).getContainerInterface();
|
||||
when(mSystemUiProxy
|
||||
.startRecentsActivity(any(), any(), listenerCaptor.capture(), anyBoolean()))
|
||||
.startRecentsActivity(any(), any(), listenerCaptor.capture(), anyBoolean(), any(),
|
||||
anyInt()))
|
||||
.thenReturn(true);
|
||||
when(gestureState.getRunningTaskIds(anyBoolean())).thenReturn(new int[0]);
|
||||
|
||||
runOnMainSync(() -> {
|
||||
mTaskAnimationManager.startRecentsAnimation(
|
||||
gestureState,
|
||||
new Intent(),
|
||||
mock(RecentsAnimationCallbacks.RecentsAnimationListener.class));
|
||||
|
||||
// Simulate multiple launcher destroyed events before the recents animation start
|
||||
mTaskAnimationManager.onLauncherDestroyed();
|
||||
mTaskAnimationManager.onLauncherDestroyed();
|
||||
mTaskAnimationManager.onLauncherDestroyed();
|
||||
listenerCaptor.getValue().onAnimationStart(
|
||||
controllerCompat,
|
||||
@@ -137,11 +163,80 @@ public class TaskAnimationManagerTest {
|
||||
new Bundle(),
|
||||
new TransitionInfo(0, 0));
|
||||
});
|
||||
|
||||
// Verify checks that finish was only called once
|
||||
runOnMainSync(() -> verify(controllerCompat)
|
||||
.finish(/* toHome= */ eq(false), anyBoolean(), any()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRecentsAnimationStartTimeout_cleansUpRecentsAnimation() {
|
||||
final GestureState gestureState = buildMockGestureState();
|
||||
when(mSystemUiProxy
|
||||
.startRecentsActivity(any(), any(), any(), anyBoolean(), any(), anyInt()))
|
||||
.thenReturn(true);
|
||||
|
||||
runOnMainSync(() -> {
|
||||
assertNull("Recents animation was started prematurely:",
|
||||
mTaskAnimationManager.getCurrentCallbacks());
|
||||
|
||||
mTaskAnimationManager.startRecentsAnimation(
|
||||
gestureState,
|
||||
new Intent(),
|
||||
mock(RecentsAnimationCallbacks.RecentsAnimationListener.class));
|
||||
|
||||
assertNotNull("TaskAnimationManager was cleaned up prematurely:",
|
||||
mTaskAnimationManager.getCurrentCallbacks());
|
||||
});
|
||||
|
||||
SystemClock.sleep(RECENTS_ANIMATION_START_TIMEOUT_MS);
|
||||
|
||||
runOnMainSync(() -> assertNull("TaskAnimationManager was not cleaned up after the timeout:",
|
||||
mTaskAnimationManager.getCurrentCallbacks()));
|
||||
}
|
||||
|
||||
protected static void runOnMainSync(Runnable runnable) {
|
||||
InstrumentationRegistry.getInstrumentation().runOnMainSync(runnable);
|
||||
}
|
||||
|
||||
private GestureState buildMockGestureState() {
|
||||
final GestureState gestureState = mock(GestureState.class);
|
||||
|
||||
doReturn(mock(LauncherActivityInterface.class)).when(gestureState).getContainerInterface();
|
||||
when(gestureState.getRunningTaskIds(anyBoolean())).thenReturn(new int[0]);
|
||||
|
||||
return gestureState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invokes maybeStartHomeAction on the given TaskAnimationManager and verifies whether the
|
||||
* provided Runnable was invoked, based on the expectedResult.
|
||||
*
|
||||
* @param taskAnimationManager The TaskAnimationManager instance to test.
|
||||
* @param expectedResult True if the Runnable is expected to be invoked, false otherwise.
|
||||
*/
|
||||
private void verifyCanStartHomeAction(TaskAnimationManager taskAnimationManager,
|
||||
Boolean expectedResult) {
|
||||
Runnable mockRunnable = mock(Runnable.class);
|
||||
taskAnimationManager.maybeStartHomeAction(mockRunnable);
|
||||
if (expectedResult) {
|
||||
verify(mockRunnable).run();
|
||||
} else {
|
||||
verify(mockRunnable, never()).run();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_ENABLE_REJECT_HOME_TRANSITION)
|
||||
public void maybeStartHomeAction_withRejectHomeTransitionEnabled() {
|
||||
verifyCanStartHomeAction(mTaskAnimationManager, true);
|
||||
verifyCanStartHomeAction(mTaskAnimationManagerWithExternalDisplay, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(Flags.FLAG_ENABLE_REJECT_HOME_TRANSITION)
|
||||
public void maybeStartHomeAction_withRejectHomeTransitionDisabled() {
|
||||
verifyCanStartHomeAction(mTaskAnimationManager, true);
|
||||
verifyCanStartHomeAction(mTaskAnimationManagerWithExternalDisplay, true);
|
||||
}
|
||||
}
|
||||
+21
-2
@@ -20,6 +20,7 @@ import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.ArgumentMatchers.anyLong;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
@@ -27,8 +28,14 @@ import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import androidx.test.filters.SmallTest;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
|
||||
import com.android.launcher3.logging.StatsLogManager;
|
||||
import com.android.launcher3.util.VibratorWrapper;
|
||||
import com.android.quickstep.DeviceConfigWrapper;
|
||||
import com.android.quickstep.NavHandle;
|
||||
import com.android.quickstep.TopTaskTracker;
|
||||
import com.android.quickstep.util.ContextualSearchHapticManager;
|
||||
import com.android.quickstep.util.ContextualSearchInvoker;
|
||||
import com.android.quickstep.util.ContextualSearchStateManager;
|
||||
import com.android.quickstep.util.TestExtensions;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -43,12 +50,24 @@ public class NavHandleLongPressHandlerTest {
|
||||
|
||||
private NavHandleLongPressHandler mLongPressHandler;
|
||||
@Mock private NavHandle mNavHandle;
|
||||
@Mock VibratorWrapper mVibratorWrapper;
|
||||
@Mock ContextualSearchHapticManager mContextualSearchHapticManager;
|
||||
@Mock TopTaskTracker mTopTaskTracker;
|
||||
@Mock StatsLogManager.StatsLogManagerFactory mStatsLogManagerFactory;
|
||||
@Mock StatsLogManager mStatsLogManager;
|
||||
@Mock ContextualSearchStateManager mContextualSearchStateManager;
|
||||
@Mock ContextualSearchInvoker mContextualSearchInvoker;
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
Context context = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
mLongPressHandler = new NavHandleLongPressHandler(context);
|
||||
Context context = InstrumentationRegistry.getInstrumentation()
|
||||
.getTargetContext().getApplicationContext();
|
||||
when(mStatsLogManagerFactory.create(context)).thenReturn(mStatsLogManager);
|
||||
mLongPressHandler = new NavHandleLongPressHandler(context, mVibratorWrapper,
|
||||
mContextualSearchHapticManager, mTopTaskTracker, mStatsLogManagerFactory,
|
||||
mContextualSearchStateManager, mContextualSearchInvoker);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+17
-13
@@ -40,29 +40,37 @@ import com.android.launcher3.util.SettingsCache
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Answers
|
||||
import org.mockito.ArgumentCaptor
|
||||
import org.mockito.Captor
|
||||
import org.mockito.Mock
|
||||
import org.mockito.MockitoAnnotations
|
||||
import org.mockito.kotlin.any
|
||||
import org.mockito.junit.MockitoJUnit
|
||||
import org.mockito.kotlin.atLeastOnce
|
||||
import org.mockito.kotlin.capture
|
||||
import org.mockito.kotlin.doReturn
|
||||
import org.mockito.kotlin.verify
|
||||
import org.mockito.kotlin.whenever
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class SettingsChangeLoggerTest {
|
||||
|
||||
@get:Rule val mockito = MockitoJUnit.rule()
|
||||
|
||||
private val mContext: Context = ApplicationProvider.getApplicationContext()
|
||||
|
||||
private val mInstanceId = InstanceId.fakeInstanceId(1)
|
||||
|
||||
private lateinit var mSystemUnderTest: SettingsChangeLogger
|
||||
|
||||
@Mock private lateinit var mStatsLogFactory: StatsLogManager.StatsLogManagerFactory
|
||||
|
||||
@Mock private lateinit var mStatsLogManager: StatsLogManager
|
||||
|
||||
@Mock private lateinit var mMockLogger: StatsLogManager.StatsLogger
|
||||
@Mock(answer = Answers.RETURNS_SELF)
|
||||
private lateinit var mMockLogger: StatsLogManager.StatsLogger
|
||||
@Mock private lateinit var mTracker: DaggerSingletonTracker
|
||||
private var displayController: DisplayController = DisplayController.INSTANCE.get(mContext)
|
||||
private var settingsCache: SettingsCache = SettingsCache.INSTANCE.get(mContext)
|
||||
@@ -77,10 +85,8 @@ class SettingsChangeLoggerTest {
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
|
||||
whenever(mStatsLogFactory.create(mContext)).doReturn(mStatsLogManager)
|
||||
whenever(mStatsLogManager.logger()).doReturn(mMockLogger)
|
||||
whenever(mStatsLogManager.logger().withInstanceId(any())).doReturn(mMockLogger)
|
||||
mDefaultThemedIcons = themeManager.isMonoThemeEnabled
|
||||
mDefaultAllowRotation = LauncherPrefs.get(mContext).get(ALLOW_ROTATION)
|
||||
// To match the default value of THEMED_ICONS
|
||||
@@ -91,10 +97,10 @@ class SettingsChangeLoggerTest {
|
||||
mSystemUnderTest =
|
||||
SettingsChangeLogger(
|
||||
mContext,
|
||||
mStatsLogManager,
|
||||
mTracker,
|
||||
displayController,
|
||||
settingsCache,
|
||||
mStatsLogFactory,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -109,17 +115,16 @@ class SettingsChangeLoggerTest {
|
||||
val systemUnderTest =
|
||||
SettingsChangeLogger(
|
||||
mContext,
|
||||
mStatsLogManager,
|
||||
mTracker,
|
||||
displayController,
|
||||
settingsCache,
|
||||
mStatsLogFactory,
|
||||
)
|
||||
|
||||
assertThat(systemUnderTest.loggingPrefs[ALLOW_ROTATION_PREFERENCE_KEY]!!.defaultValue)
|
||||
.isFalse()
|
||||
assertThat(systemUnderTest.loggingPrefs[ADD_ICON_PREFERENCE_KEY]!!.defaultValue).isTrue()
|
||||
assertThat(systemUnderTest.loggingPrefs[OVERVIEW_SUGGESTED_ACTIONS]!!.defaultValue).isTrue()
|
||||
assertThat(systemUnderTest.loggingPrefs[SMARTSPACE_ON_HOME_SCREEN]!!.defaultValue).isTrue()
|
||||
assertThat(systemUnderTest.loggingPrefs[KEY_ENABLE_MINUS_ONE]!!.defaultValue).isTrue()
|
||||
}
|
||||
|
||||
@@ -127,7 +132,7 @@ class SettingsChangeLoggerTest {
|
||||
fun logSnapshot_defaultValue() {
|
||||
mSystemUnderTest.logSnapshot(mInstanceId)
|
||||
|
||||
verify(mMockLogger, atLeastOnce()).log(mEventCaptor.capture())
|
||||
verify(mMockLogger, atLeastOnce()).log(capture(mEventCaptor))
|
||||
val capturedEvents = mEventCaptor.allValues
|
||||
assertThat(capturedEvents.isNotEmpty()).isTrue()
|
||||
verifyDefaultEvent(capturedEvents)
|
||||
@@ -140,10 +145,10 @@ class SettingsChangeLoggerTest {
|
||||
LauncherPrefs.get(mContext).put(item = ALLOW_ROTATION, value = true)
|
||||
|
||||
// This a new object so the values of mLoggablePrefs will be different
|
||||
SettingsChangeLogger(mContext, mStatsLogManager, mTracker, displayController, settingsCache)
|
||||
SettingsChangeLogger(mContext, mTracker, displayController, settingsCache, mStatsLogFactory)
|
||||
.logSnapshot(mInstanceId)
|
||||
|
||||
verify(mMockLogger, atLeastOnce()).log(mEventCaptor.capture())
|
||||
verify(mMockLogger, atLeastOnce()).log(capture(mEventCaptor))
|
||||
val capturedEvents = mEventCaptor.allValues
|
||||
assertThat(capturedEvents.isNotEmpty()).isTrue()
|
||||
verifyDefaultEvent(capturedEvents)
|
||||
@@ -168,7 +173,6 @@ class SettingsChangeLoggerTest {
|
||||
companion object {
|
||||
private const val KEY_ENABLE_MINUS_ONE = "pref_enable_minus_one"
|
||||
private const val OVERVIEW_SUGGESTED_ACTIONS = "pref_overview_action_suggestions"
|
||||
private const val SMARTSPACE_ON_HOME_SCREEN = "pref_smartspace_home_screen"
|
||||
|
||||
private const val LAUNCHER_GOOGLE_APP_SWIPE_LEFT_ENABLED = 617
|
||||
}
|
||||
|
||||
+3
-2
@@ -21,7 +21,7 @@ import com.android.quickstep.TaskIconCache.TaskCacheEntry
|
||||
import com.android.quickstep.task.thumbnail.data.TaskIconDataSource
|
||||
import com.android.systemui.shared.recents.model.Task
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import kotlinx.coroutines.yield
|
||||
import kotlinx.coroutines.delay
|
||||
import org.mockito.kotlin.mock
|
||||
import org.mockito.kotlin.whenever
|
||||
|
||||
@@ -34,7 +34,8 @@ class FakeTaskIconDataSource : TaskIconDataSource {
|
||||
/** Retrieves and sets an icon on [task] from [taskIdToDrawable]. */
|
||||
override suspend fun getIcon(task: Task): TaskCacheEntry {
|
||||
while (task.key.id in completionPrevented) {
|
||||
yield()
|
||||
// yield doesn't work here with an UnconfinedTestDispatcher
|
||||
delay(1L)
|
||||
}
|
||||
return TaskCacheEntry(
|
||||
taskIdToDrawable.getValue(task.key.id),
|
||||
|
||||
+7
-2
@@ -20,7 +20,7 @@ import android.graphics.Bitmap
|
||||
import com.android.quickstep.task.thumbnail.data.TaskThumbnailDataSource
|
||||
import com.android.systemui.shared.recents.model.Task
|
||||
import com.android.systemui.shared.recents.model.ThumbnailData
|
||||
import kotlinx.coroutines.yield
|
||||
import kotlinx.coroutines.delay
|
||||
import org.mockito.kotlin.mock
|
||||
|
||||
class FakeTaskThumbnailDataSource : TaskThumbnailDataSource {
|
||||
@@ -37,7 +37,8 @@ class FakeTaskThumbnailDataSource : TaskThumbnailDataSource {
|
||||
getThumbnailCalls[task.key.id] = (getThumbnailCalls[task.key.id] ?: 0) + 1
|
||||
|
||||
while (task.key.id in completionPrevented) {
|
||||
yield()
|
||||
// yield doesn't work here with an UnconfinedTestDispatcher
|
||||
delay(1L)
|
||||
}
|
||||
return ThumbnailData(
|
||||
thumbnail = taskIdToBitmap[task.key.id],
|
||||
@@ -54,4 +55,8 @@ class FakeTaskThumbnailDataSource : TaskThumbnailDataSource {
|
||||
fun completeLoadingForTask(taskId: Int) {
|
||||
completionPrevented.remove(taskId)
|
||||
}
|
||||
|
||||
fun completeLoading() {
|
||||
completionPrevented.clear()
|
||||
}
|
||||
}
|
||||
+17
-6
@@ -17,24 +17,30 @@
|
||||
package com.android.quickstep.recents.data
|
||||
|
||||
import android.graphics.drawable.Drawable
|
||||
import androidx.core.util.forEach
|
||||
import androidx.core.util.putAll
|
||||
import com.android.systemui.shared.recents.model.Task
|
||||
import com.android.systemui.shared.recents.model.ThumbnailData
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.combine
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.flow.update
|
||||
|
||||
class FakeTasksRepository : RecentTasksRepository {
|
||||
private var thumbnailDataMap: Map<Int, ThumbnailData> = emptyMap()
|
||||
private var taskIconDataMap: Map<Int, FakeIconData> = emptyMap()
|
||||
private var tasks: MutableStateFlow<List<Task>> = MutableStateFlow(emptyList())
|
||||
private var visibleTasks: MutableStateFlow<Set<Int>> = MutableStateFlow(emptySet())
|
||||
private var visibleTasks: MutableStateFlow<Map<Int, Set<Int>>> = MutableStateFlow(mapOf())
|
||||
|
||||
override fun getAllTaskData(forceRefresh: Boolean): Flow<List<Task>> = tasks
|
||||
override fun getAllTaskData(displayId: Int, forceRefresh: Boolean): Flow<List<Task>> =
|
||||
tasks.map { it.filter { it.key.displayId == displayId }.toList() }
|
||||
|
||||
override fun getTaskDataById(taskId: Int): Flow<Task?> =
|
||||
combine(getAllTaskData(), visibleTasks) { taskList, visibleTasks ->
|
||||
taskList.filter { visibleTasks.contains(it.key.id) }
|
||||
combine(tasks, visibleTasks) { taskList, visibleTasks ->
|
||||
val allVisibleTasks = mutableSetOf<Int>()
|
||||
visibleTasks.forEach { _, value -> allVisibleTasks.addAll(value) }
|
||||
taskList.filter { allVisibleTasks.contains(it.key.id) }
|
||||
}
|
||||
.map { taskList ->
|
||||
val task = taskList.firstOrNull { it.key.id == taskId } ?: return@map null
|
||||
@@ -52,8 +58,13 @@ class FakeTasksRepository : RecentTasksRepository {
|
||||
override fun getCurrentThumbnailById(taskId: Int): ThumbnailData? =
|
||||
tasks.value.firstOrNull { it.key.id == taskId }?.thumbnail
|
||||
|
||||
override fun setVisibleTasks(visibleTaskIdList: Set<Int>) {
|
||||
visibleTasks.value = visibleTaskIdList
|
||||
override fun setVisibleTasks(displayId: Int, visibleTaskIdList: Set<Int>) {
|
||||
visibleTasks.update {
|
||||
val newVisibleTasks = mutableMapOf<Int, Set<Int>>()
|
||||
newVisibleTasks.putAll(it)
|
||||
newVisibleTasks[displayId] = visibleTaskIdList
|
||||
newVisibleTasks
|
||||
}
|
||||
tasks.value =
|
||||
tasks.value.map {
|
||||
it.apply {
|
||||
|
||||
+194
-46
@@ -23,13 +23,13 @@ import android.graphics.Rect
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.view.Display.DEFAULT_DISPLAY
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import com.android.launcher3.util.SplitConfigurationOptions
|
||||
import com.android.launcher3.util.TestDispatcherProvider
|
||||
import com.android.quickstep.util.DesktopTask
|
||||
import com.android.quickstep.util.SingleTask
|
||||
import com.android.quickstep.util.SplitTask
|
||||
import com.android.systemui.shared.recents.model.Task
|
||||
import com.android.systemui.shared.recents.model.ThumbnailData
|
||||
import com.android.wm.shell.shared.split.SplitBounds
|
||||
import com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_2_50_50
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
@@ -39,7 +39,9 @@ import kotlinx.coroutines.flow.toList
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.test.TestScope
|
||||
import kotlinx.coroutines.test.UnconfinedTestDispatcher
|
||||
import kotlinx.coroutines.test.advanceUntilIdle
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Mockito.spy
|
||||
@@ -51,22 +53,39 @@ import org.mockito.kotlin.whenever
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class TasksRepositoryTest {
|
||||
private val tasks = (0..5).map(::createTaskWithId)
|
||||
private val secondaryTasks = (6..11).map(::createTaskWithIdForSecondaryDisplay)
|
||||
private val defaultTaskList =
|
||||
listOf(
|
||||
SingleTask(tasks[0]),
|
||||
SplitTask(
|
||||
tasks[1],
|
||||
tasks[2],
|
||||
SplitConfigurationOptions.SplitBounds(
|
||||
SplitBounds(
|
||||
/* leftTopBounds = */ Rect(),
|
||||
/* rightBottomBounds = */ Rect(),
|
||||
/* leftTopTaskId = */ -1,
|
||||
/* rightBottomTaskId = */ -1,
|
||||
/* leftTopTaskId = */ 1,
|
||||
/* rightBottomTaskId = */ 2,
|
||||
/* snapPosition = */ SNAP_TO_2_50_50,
|
||||
),
|
||||
),
|
||||
DesktopTask(deskId = 0, DEFAULT_DISPLAY, tasks.subList(3, 6)),
|
||||
)
|
||||
private val secondaryTaskList =
|
||||
listOf(
|
||||
SingleTask(secondaryTasks[0]),
|
||||
SplitTask(
|
||||
secondaryTasks[1],
|
||||
secondaryTasks[2],
|
||||
SplitBounds(
|
||||
/* leftTopBounds = */ Rect(),
|
||||
/* rightBottomBounds = */ Rect(),
|
||||
/* leftTopTaskId = */ 7,
|
||||
/* rightBottomTaskId = */ 8,
|
||||
/* snapPosition = */ SNAP_TO_2_50_50,
|
||||
),
|
||||
),
|
||||
DesktopTask(deskId = 1, SECONDARY_DISPLAY, secondaryTasks.subList(3, 6)),
|
||||
)
|
||||
private val recentsModel = FakeRecentTasksDataSource()
|
||||
private val taskThumbnailDataSource = FakeTaskThumbnailDataSource()
|
||||
private val taskIconDataSource = FakeTaskIconDataSource()
|
||||
@@ -87,18 +106,25 @@ class TasksRepositoryTest {
|
||||
TestDispatcherProvider(dispatcher),
|
||||
)
|
||||
|
||||
@Before
|
||||
fun cleanupDataSources() {
|
||||
taskThumbnailDataSource.completeLoading()
|
||||
taskIconDataSource.completeLoading()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getAllTaskDataReturnsFlattenedListOfTasks() =
|
||||
testScope.runTest {
|
||||
recentsModel.seedTasks(defaultTaskList)
|
||||
assertThat(systemUnderTest.getAllTaskData(forceRefresh = true).first()).isEqualTo(tasks)
|
||||
assertThat(systemUnderTest.getAllTaskData(DEFAULT_DISPLAY, forceRefresh = true).first())
|
||||
.isEqualTo(tasks)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getTaskDataByIdReturnsSpecificTask() =
|
||||
testScope.runTest {
|
||||
recentsModel.seedTasks(defaultTaskList)
|
||||
systemUnderTest.getAllTaskData(forceRefresh = true)
|
||||
systemUnderTest.getAllTaskData(DEFAULT_DISPLAY, forceRefresh = true)
|
||||
|
||||
assertThat(systemUnderTest.getTaskDataById(2).first()).isEqualTo(tasks[2])
|
||||
}
|
||||
@@ -107,7 +133,7 @@ class TasksRepositoryTest {
|
||||
fun getThumbnailByIdReturnsNullWithNoLoadedThumbnails() =
|
||||
testScope.runTest {
|
||||
recentsModel.seedTasks(defaultTaskList)
|
||||
systemUnderTest.getAllTaskData(forceRefresh = true)
|
||||
systemUnderTest.getAllTaskData(DEFAULT_DISPLAY, forceRefresh = true)
|
||||
|
||||
assertThat(systemUnderTest.getThumbnailById(1).first()).isNull()
|
||||
}
|
||||
@@ -116,7 +142,7 @@ class TasksRepositoryTest {
|
||||
fun getCurrentThumbnailByIdReturnsNullWithNoLoadedThumbnails() =
|
||||
testScope.runTest {
|
||||
recentsModel.seedTasks(defaultTaskList)
|
||||
systemUnderTest.getAllTaskData(forceRefresh = true)
|
||||
systemUnderTest.getAllTaskData(DEFAULT_DISPLAY, forceRefresh = true)
|
||||
|
||||
assertThat(systemUnderTest.getCurrentThumbnailById(1)).isNull()
|
||||
}
|
||||
@@ -125,10 +151,10 @@ class TasksRepositoryTest {
|
||||
fun getThumbnailByIdReturnsThumbnailWithLoadedThumbnails() =
|
||||
testScope.runTest {
|
||||
recentsModel.seedTasks(defaultTaskList)
|
||||
systemUnderTest.getAllTaskData(forceRefresh = true)
|
||||
systemUnderTest.getAllTaskData(DEFAULT_DISPLAY, forceRefresh = true)
|
||||
val bitmap1 = taskThumbnailDataSource.taskIdToBitmap[1]
|
||||
|
||||
systemUnderTest.setVisibleTasks(setOf(1))
|
||||
systemUnderTest.setVisibleTasks(DEFAULT_DISPLAY, setOf(1))
|
||||
|
||||
assertThat(systemUnderTest.getThumbnailById(1).first()!!.thumbnail).isEqualTo(bitmap1)
|
||||
}
|
||||
@@ -137,33 +163,55 @@ class TasksRepositoryTest {
|
||||
fun whenThumbnailIsLoaded_getAllTaskData_usesPreviousLoadedThumbnailAndIcon() =
|
||||
testScope.runTest {
|
||||
recentsModel.seedTasks(defaultTaskList)
|
||||
systemUnderTest.getAllTaskData(forceRefresh = true)
|
||||
systemUnderTest.getAllTaskData(DEFAULT_DISPLAY, forceRefresh = true)
|
||||
val bitmap1 = taskThumbnailDataSource.taskIdToBitmap[1]
|
||||
|
||||
systemUnderTest.setVisibleTasks(setOf(1))
|
||||
systemUnderTest.setVisibleTasks(DEFAULT_DISPLAY, setOf(1))
|
||||
assertThat(systemUnderTest.getThumbnailById(1).first()!!.thumbnail).isEqualTo(bitmap1)
|
||||
|
||||
systemUnderTest.getAllTaskData(forceRefresh = true)
|
||||
systemUnderTest.getAllTaskData(DEFAULT_DISPLAY, forceRefresh = true)
|
||||
assertThat(systemUnderTest.getThumbnailById(1).first()!!.thumbnail).isEqualTo(bitmap1)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getAllTaskData_copiesPreviouslyLoadedImagesForTasksStillPresent() =
|
||||
testScope.runTest {
|
||||
recentsModel.seedTasks(defaultTaskList)
|
||||
systemUnderTest.getAllTaskData(DEFAULT_DISPLAY, forceRefresh = true)
|
||||
systemUnderTest.setVisibleTasks(DEFAULT_DISPLAY, setOf(0, 1))
|
||||
|
||||
// Seed new task with same id
|
||||
val newTask0 = SingleTask(createTaskWithId(0))
|
||||
val newSeededTasks =
|
||||
defaultTaskList.map {
|
||||
if (it is SingleTask && it.task.key.id == 0) newTask0 else it
|
||||
}
|
||||
recentsModel.seedTasks(newSeededTasks)
|
||||
systemUnderTest.getAllTaskData(DEFAULT_DISPLAY, forceRefresh = true)
|
||||
|
||||
// Assert no additional loads, assert images present
|
||||
assertThat(systemUnderTest.getThumbnailById(0).first()?.thumbnail)
|
||||
.isEqualTo(taskThumbnailDataSource.taskIdToBitmap[0])
|
||||
assertThat(taskThumbnailDataSource.getNumberOfGetThumbnailCalls(0)).isEqualTo(1)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getAllTaskData_clearsPreviouslyLoadedImagesForRemovedTasks() =
|
||||
testScope.runTest {
|
||||
// Setup data
|
||||
recentsModel.seedTasks(defaultTaskList)
|
||||
systemUnderTest.getAllTaskData(forceRefresh = true)
|
||||
systemUnderTest.getAllTaskData(DEFAULT_DISPLAY, forceRefresh = true)
|
||||
val bitmap1 = taskThumbnailDataSource.taskIdToBitmap[1]
|
||||
|
||||
// Load images for task 1
|
||||
systemUnderTest.setVisibleTasks(setOf(1))
|
||||
systemUnderTest.setVisibleTasks(DEFAULT_DISPLAY, setOf(1))
|
||||
assertThat(systemUnderTest.getThumbnailById(1).first()!!.thumbnail).isEqualTo(bitmap1)
|
||||
|
||||
// Remove task 1 from "all data"
|
||||
recentsModel.seedTasks(
|
||||
defaultTaskList.filterNot { groupTask -> groupTask.tasks.any { it.key.id == 1 } }
|
||||
)
|
||||
systemUnderTest.getAllTaskData(forceRefresh = true)
|
||||
systemUnderTest.getAllTaskData(DEFAULT_DISPLAY, forceRefresh = true)
|
||||
|
||||
// Assert task 1 was fully removed
|
||||
assertThat(systemUnderTest.getThumbnailById(1).first()?.thumbnail).isNull()
|
||||
@@ -174,10 +222,10 @@ class TasksRepositoryTest {
|
||||
fun getCurrentThumbnailByIdReturnsThumbnailWithLoadedThumbnails() =
|
||||
testScope.runTest {
|
||||
recentsModel.seedTasks(defaultTaskList)
|
||||
systemUnderTest.getAllTaskData(forceRefresh = true)
|
||||
systemUnderTest.getAllTaskData(DEFAULT_DISPLAY, forceRefresh = true)
|
||||
val bitmap1 = taskThumbnailDataSource.taskIdToBitmap[1]
|
||||
|
||||
systemUnderTest.setVisibleTasks(setOf(1))
|
||||
systemUnderTest.setVisibleTasks(DEFAULT_DISPLAY, setOf(1))
|
||||
|
||||
assertThat(systemUnderTest.getCurrentThumbnailById(1)?.thumbnail).isEqualTo(bitmap1)
|
||||
}
|
||||
@@ -188,9 +236,9 @@ class TasksRepositoryTest {
|
||||
recentsModel.seedTasks(defaultTaskList)
|
||||
val bitmap1 = taskThumbnailDataSource.taskIdToBitmap[1]
|
||||
val bitmap2 = taskThumbnailDataSource.taskIdToBitmap[2]
|
||||
systemUnderTest.getAllTaskData(forceRefresh = true)
|
||||
systemUnderTest.getAllTaskData(DEFAULT_DISPLAY, forceRefresh = true)
|
||||
|
||||
systemUnderTest.setVisibleTasks(setOf(1, 2))
|
||||
systemUnderTest.setVisibleTasks(DEFAULT_DISPLAY, setOf(1, 2))
|
||||
|
||||
assertThat(systemUnderTest.getTaskDataById(1).first()!!.thumbnail!!.thumbnail)
|
||||
.isEqualTo(bitmap1)
|
||||
@@ -202,9 +250,9 @@ class TasksRepositoryTest {
|
||||
fun setVisibleTasksPopulatesIcons() =
|
||||
testScope.runTest {
|
||||
recentsModel.seedTasks(defaultTaskList)
|
||||
systemUnderTest.getAllTaskData(forceRefresh = true)
|
||||
systemUnderTest.getAllTaskData(DEFAULT_DISPLAY, forceRefresh = true)
|
||||
|
||||
systemUnderTest.setVisibleTasks(setOf(1, 2))
|
||||
systemUnderTest.setVisibleTasks(DEFAULT_DISPLAY, setOf(1, 2))
|
||||
|
||||
systemUnderTest
|
||||
.getTaskDataById(1)
|
||||
@@ -221,16 +269,16 @@ class TasksRepositoryTest {
|
||||
testScope.runTest {
|
||||
recentsModel.seedTasks(defaultTaskList)
|
||||
val bitmap2 = taskThumbnailDataSource.taskIdToBitmap[2]
|
||||
systemUnderTest.getAllTaskData(forceRefresh = true)
|
||||
systemUnderTest.getAllTaskData(DEFAULT_DISPLAY, forceRefresh = true)
|
||||
|
||||
systemUnderTest.setVisibleTasks(setOf(1, 2))
|
||||
systemUnderTest.setVisibleTasks(DEFAULT_DISPLAY, setOf(1, 2))
|
||||
|
||||
assertThat(systemUnderTest.getTaskDataById(2).first()!!.thumbnail!!.thumbnail)
|
||||
.isEqualTo(bitmap2)
|
||||
|
||||
// Prevent new loading of Bitmaps
|
||||
taskThumbnailDataSource.preventThumbnailLoad(2)
|
||||
systemUnderTest.setVisibleTasks(setOf(2, 3))
|
||||
systemUnderTest.setVisibleTasks(DEFAULT_DISPLAY, setOf(2, 3))
|
||||
|
||||
assertThat(systemUnderTest.getTaskDataById(2).first()!!.thumbnail!!.thumbnail)
|
||||
.isEqualTo(bitmap2)
|
||||
@@ -240,9 +288,9 @@ class TasksRepositoryTest {
|
||||
fun changingVisibleTasksContainsAlreadyPopulatedIcons() =
|
||||
testScope.runTest {
|
||||
recentsModel.seedTasks(defaultTaskList)
|
||||
systemUnderTest.getAllTaskData(forceRefresh = true)
|
||||
systemUnderTest.getAllTaskData(DEFAULT_DISPLAY, forceRefresh = true)
|
||||
|
||||
systemUnderTest.setVisibleTasks(setOf(1, 2))
|
||||
systemUnderTest.setVisibleTasks(DEFAULT_DISPLAY, setOf(1, 2))
|
||||
|
||||
systemUnderTest
|
||||
.getTaskDataById(2)
|
||||
@@ -251,7 +299,7 @@ class TasksRepositoryTest {
|
||||
|
||||
// Prevent new loading of Drawables
|
||||
taskIconDataSource.preventIconLoad(2)
|
||||
systemUnderTest.setVisibleTasks(setOf(2, 3))
|
||||
systemUnderTest.setVisibleTasks(DEFAULT_DISPLAY, setOf(2, 3))
|
||||
|
||||
systemUnderTest
|
||||
.getTaskDataById(2)
|
||||
@@ -264,15 +312,15 @@ class TasksRepositoryTest {
|
||||
testScope.runTest {
|
||||
recentsModel.seedTasks(defaultTaskList)
|
||||
val bitmap2 = taskThumbnailDataSource.taskIdToBitmap[2]
|
||||
systemUnderTest.getAllTaskData(forceRefresh = true)
|
||||
systemUnderTest.getAllTaskData(DEFAULT_DISPLAY, forceRefresh = true)
|
||||
|
||||
systemUnderTest.setVisibleTasks(setOf(1, 2))
|
||||
systemUnderTest.setVisibleTasks(DEFAULT_DISPLAY, setOf(1, 2))
|
||||
|
||||
val task2 = systemUnderTest.getTaskDataById(2).first()!!
|
||||
assertThat(task2.thumbnail!!.thumbnail).isEqualTo(bitmap2)
|
||||
task2.assertHasIconDataFromSource(taskIconDataSource)
|
||||
|
||||
systemUnderTest.setVisibleTasks(setOf(0, 1))
|
||||
systemUnderTest.setVisibleTasks(DEFAULT_DISPLAY, setOf(0, 1))
|
||||
|
||||
val task2AfterVisibleTasksChanged = systemUnderTest.getTaskDataById(2).first()!!
|
||||
assertThat(task2AfterVisibleTasksChanged.thumbnail).isNull()
|
||||
@@ -289,7 +337,7 @@ class TasksRepositoryTest {
|
||||
val bitmap2 = taskThumbnailDataSource.taskIdToBitmap[2]
|
||||
|
||||
// Setup TasksRepository
|
||||
systemUnderTest.getAllTaskData(forceRefresh = true)
|
||||
systemUnderTest.getAllTaskData(DEFAULT_DISPLAY, forceRefresh = true)
|
||||
|
||||
val task2DataFlow = systemUnderTest.getTaskDataById(2)
|
||||
val task2BitmapValues = mutableListOf<Bitmap?>()
|
||||
@@ -300,7 +348,7 @@ class TasksRepositoryTest {
|
||||
// Check for first emission
|
||||
assertThat(task2BitmapValues.single()).isNull()
|
||||
|
||||
systemUnderTest.setVisibleTasks(setOf(2))
|
||||
systemUnderTest.setVisibleTasks(DEFAULT_DISPLAY, setOf(2))
|
||||
// Check for second emission
|
||||
assertThat(task2BitmapValues).isEqualTo(listOf(null, bitmap2))
|
||||
}
|
||||
@@ -309,8 +357,8 @@ class TasksRepositoryTest {
|
||||
fun onTaskThumbnailChanged_setsNewThumbnailDataOnTask() =
|
||||
testScope.runTest {
|
||||
recentsModel.seedTasks(defaultTaskList)
|
||||
systemUnderTest.getAllTaskData(forceRefresh = true)
|
||||
systemUnderTest.setVisibleTasks(setOf(1))
|
||||
systemUnderTest.getAllTaskData(DEFAULT_DISPLAY, forceRefresh = true)
|
||||
systemUnderTest.setVisibleTasks(DEFAULT_DISPLAY, setOf(1))
|
||||
|
||||
val expectedThumbnailData = createThumbnailData()
|
||||
val expectedPreviousBitmap = taskThumbnailDataSource.taskIdToBitmap[1]
|
||||
@@ -331,9 +379,9 @@ class TasksRepositoryTest {
|
||||
testScope.runTest {
|
||||
taskThumbnailDataSource.highResEnabled = false
|
||||
recentsModel.seedTasks(defaultTaskList)
|
||||
systemUnderTest.getAllTaskData(forceRefresh = true)
|
||||
systemUnderTest.getAllTaskData(DEFAULT_DISPLAY, forceRefresh = true)
|
||||
|
||||
systemUnderTest.setVisibleTasks(setOf(1))
|
||||
systemUnderTest.setVisibleTasks(DEFAULT_DISPLAY, setOf(1))
|
||||
|
||||
val expectedBitmap = mock<Bitmap>()
|
||||
val expectedPreviousBitmap = taskThumbnailDataSource.taskIdToBitmap[1]
|
||||
@@ -362,9 +410,9 @@ class TasksRepositoryTest {
|
||||
testScope.runTest {
|
||||
taskThumbnailDataSource.highResEnabled = false
|
||||
recentsModel.seedTasks(defaultTaskList)
|
||||
systemUnderTest.getAllTaskData(forceRefresh = true)
|
||||
systemUnderTest.getAllTaskData(DEFAULT_DISPLAY, forceRefresh = true)
|
||||
|
||||
systemUnderTest.setVisibleTasks(setOf(1))
|
||||
systemUnderTest.setVisibleTasks(DEFAULT_DISPLAY, setOf(1))
|
||||
|
||||
val invisibleTaskId = 2
|
||||
val taskDataFlow = systemUnderTest.getTaskDataById(invisibleTaskId)
|
||||
@@ -386,9 +434,9 @@ class TasksRepositoryTest {
|
||||
testScope.runTest {
|
||||
taskThumbnailDataSource.highResEnabled = true
|
||||
recentsModel.seedTasks(defaultTaskList)
|
||||
systemUnderTest.getAllTaskData(forceRefresh = true)
|
||||
systemUnderTest.getAllTaskData(DEFAULT_DISPLAY, forceRefresh = true)
|
||||
|
||||
systemUnderTest.setVisibleTasks(setOf(1))
|
||||
systemUnderTest.setVisibleTasks(DEFAULT_DISPLAY, setOf(1))
|
||||
|
||||
val expectedBitmap = mock<Bitmap>()
|
||||
val expectedPreviousBitmap = taskThumbnailDataSource.taskIdToBitmap[1]
|
||||
@@ -416,9 +464,9 @@ class TasksRepositoryTest {
|
||||
fun onTaskIconChanged_setsNewIconOnTask() =
|
||||
testScope.runTest {
|
||||
recentsModel.seedTasks(defaultTaskList)
|
||||
systemUnderTest.getAllTaskData(forceRefresh = true)
|
||||
systemUnderTest.getAllTaskData(DEFAULT_DISPLAY, forceRefresh = true)
|
||||
|
||||
systemUnderTest.setVisibleTasks(setOf(1))
|
||||
systemUnderTest.setVisibleTasks(DEFAULT_DISPLAY, setOf(1))
|
||||
|
||||
val expectedIcon = FakeTaskIconDataSource.mockCopyableDrawable()
|
||||
val expectedPreviousIcon = taskIconDataSource.taskIdToDrawable[1]
|
||||
@@ -439,7 +487,7 @@ class TasksRepositoryTest {
|
||||
fun setVisibleTasks_multipleTimesWithDifferentTasks_reusesThumbnailRequests() =
|
||||
testScope.runTest {
|
||||
recentsModel.seedTasks(defaultTaskList)
|
||||
systemUnderTest.getAllTaskData(forceRefresh = true)
|
||||
systemUnderTest.getAllTaskData(DEFAULT_DISPLAY, forceRefresh = true)
|
||||
|
||||
val taskDataFlow = systemUnderTest.getTaskDataById(1)
|
||||
val task1IconValues = mutableListOf<Drawable?>()
|
||||
@@ -447,16 +495,115 @@ class TasksRepositoryTest {
|
||||
taskDataFlow.map { it?.icon }.toList(task1IconValues)
|
||||
}
|
||||
|
||||
systemUnderTest.setVisibleTasks(setOf(1))
|
||||
systemUnderTest.setVisibleTasks(DEFAULT_DISPLAY, setOf(1))
|
||||
assertThat(taskThumbnailDataSource.getNumberOfGetThumbnailCalls(1)).isEqualTo(1)
|
||||
|
||||
systemUnderTest.setVisibleTasks(setOf(1, 2))
|
||||
systemUnderTest.setVisibleTasks(DEFAULT_DISPLAY, setOf(1, 2))
|
||||
assertThat(taskThumbnailDataSource.getNumberOfGetThumbnailCalls(1)).isEqualTo(1)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getTaskData_forSecondaryDisplay() =
|
||||
testScope.runTest {
|
||||
recentsModel.seedTasks(defaultTaskList + secondaryTaskList)
|
||||
|
||||
assertThat(systemUnderTest.getAllTaskData(DEFAULT_DISPLAY, forceRefresh = true).first())
|
||||
.isEqualTo(tasks)
|
||||
assertThat(
|
||||
systemUnderTest.getAllTaskData(SECONDARY_DISPLAY, forceRefresh = true).first()
|
||||
)
|
||||
.isEqualTo(secondaryTasks)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun setVisibleTasks_secondaryDisplayConnected() =
|
||||
testScope.runTest {
|
||||
recentsModel.seedTasks(defaultTaskList + secondaryTaskList)
|
||||
systemUnderTest.getAllTaskData(DEFAULT_DISPLAY, forceRefresh = true)
|
||||
systemUnderTest.getAllTaskData(SECONDARY_DISPLAY, forceRefresh = true)
|
||||
val bitmap1 = taskThumbnailDataSource.taskIdToBitmap[1]
|
||||
val bitmap6 = taskThumbnailDataSource.taskIdToBitmap[6]
|
||||
|
||||
systemUnderTest.setVisibleTasks(DEFAULT_DISPLAY, setOf(1))
|
||||
systemUnderTest.setVisibleTasks(SECONDARY_DISPLAY, setOf(6))
|
||||
|
||||
val actualThumbnails =
|
||||
(0..11).map { systemUnderTest.getThumbnailById(it).first()?.thumbnail }.toList()
|
||||
val expectedThumbnails =
|
||||
arrayOfNulls<Bitmap>(12)
|
||||
.apply {
|
||||
set(1, bitmap1)
|
||||
set(6, bitmap6)
|
||||
}
|
||||
.toList()
|
||||
assertThat(actualThumbnails).isEqualTo(expectedThumbnails)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun setVisibleTasks_displayDisconnectedBeforeImageReturns_doesNotPopulateThumbnailOrIcon() =
|
||||
testScope.runTest {
|
||||
recentsModel.seedTasks(defaultTaskList + secondaryTaskList)
|
||||
systemUnderTest.getAllTaskData(DEFAULT_DISPLAY, forceRefresh = true)
|
||||
systemUnderTest.getAllTaskData(SECONDARY_DISPLAY, forceRefresh = true)
|
||||
taskThumbnailDataSource.preventThumbnailLoad(6)
|
||||
taskIconDataSource.preventIconLoad(6)
|
||||
|
||||
val task6DataFlow = systemUnderTest.getTaskDataById(6)
|
||||
val task6Values = mutableListOf<Pair<Bitmap?, Drawable?>>()
|
||||
testScope.backgroundScope.launch {
|
||||
task6DataFlow.map { Pair(it?.thumbnail?.thumbnail, it?.icon) }.toList(task6Values)
|
||||
}
|
||||
|
||||
launch { systemUnderTest.setVisibleTasks(SECONDARY_DISPLAY, setOf(6)) }
|
||||
// Check we prevented the resources from loading
|
||||
assertThat(task6Values.distinct()).isEqualTo(listOf(Pair(null, null)))
|
||||
// Display disconnects
|
||||
launch { systemUnderTest.setVisibleTasks(SECONDARY_DISPLAY, emptySet()) }
|
||||
taskThumbnailDataSource.completeLoadingForTask(6)
|
||||
taskIconDataSource.completeLoadingForTask(6)
|
||||
testScope.advanceUntilIdle()
|
||||
// Still should not be loaded
|
||||
assertThat(task6Values.distinct()).isEqualTo(listOf(Pair(null, null)))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun onDisplayRemoved_removesAllDataForDisplay() =
|
||||
testScope.runTest {
|
||||
recentsModel.seedTasks(defaultTaskList + secondaryTaskList)
|
||||
systemUnderTest.getAllTaskData(DEFAULT_DISPLAY, forceRefresh = true)
|
||||
systemUnderTest.getAllTaskData(SECONDARY_DISPLAY, forceRefresh = true)
|
||||
systemUnderTest.setVisibleTasks(DEFAULT_DISPLAY, setOf(1))
|
||||
systemUnderTest.setVisibleTasks(SECONDARY_DISPLAY, setOf(6))
|
||||
|
||||
recentsModel.seedTasks(defaultTaskList)
|
||||
systemUnderTest.setVisibleTasks(SECONDARY_DISPLAY, emptySet())
|
||||
|
||||
for (t in 6..11) {
|
||||
assertThat(systemUnderTest.getThumbnailById(t).first()?.thumbnail).isNull()
|
||||
assertThat(systemUnderTest.getTaskDataById(t).first()?.icon).isNull()
|
||||
}
|
||||
}
|
||||
|
||||
private fun createTaskWithId(taskId: Int) =
|
||||
Task(Task.TaskKey(taskId, 0, Intent(), ComponentName("", ""), 0, 2000))
|
||||
|
||||
private fun createTaskWithIdForSecondaryDisplay(taskId: Int) =
|
||||
Task(
|
||||
Task.TaskKey(
|
||||
taskId,
|
||||
0,
|
||||
Intent(),
|
||||
ComponentName("", ""),
|
||||
0,
|
||||
2000,
|
||||
SECONDARY_DISPLAY,
|
||||
null,
|
||||
0,
|
||||
false,
|
||||
false,
|
||||
)
|
||||
)
|
||||
|
||||
private fun createThumbnailData(): ThumbnailData {
|
||||
val bitmap = mock<Bitmap>()
|
||||
whenever(bitmap.width).thenReturn(THUMBNAIL_WIDTH)
|
||||
@@ -468,5 +615,6 @@ class TasksRepositoryTest {
|
||||
companion object {
|
||||
const val THUMBNAIL_WIDTH = 100
|
||||
const val THUMBNAIL_HEIGHT = 200
|
||||
const val SECONDARY_DISPLAY = 1
|
||||
}
|
||||
}
|
||||
+112
-14
@@ -20,70 +20,166 @@ import android.content.ComponentName
|
||||
import android.content.Intent
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.ShapeDrawable
|
||||
import android.os.UserHandle
|
||||
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
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import com.android.launcher3.Flags
|
||||
import com.android.quickstep.recents.data.FakeAppTimersRepository
|
||||
import com.android.quickstep.recents.data.FakeTasksRepository
|
||||
import com.android.quickstep.recents.domain.model.TaskModel
|
||||
import com.android.systemui.shared.recents.model.Task
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import java.time.Duration
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.flow.firstOrNull
|
||||
import kotlinx.coroutines.test.TestScope
|
||||
import kotlinx.coroutines.test.UnconfinedTestDispatcher
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Mockito.anyString
|
||||
import org.mockito.Mockito.spy
|
||||
import org.mockito.Mockito.times
|
||||
import org.mockito.Mockito.verify
|
||||
import org.mockito.kotlin.any
|
||||
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class GetTaskUseCaseTest {
|
||||
@get:Rule val setFlagsRule = SetFlagsRule()
|
||||
|
||||
private val unconfinedTestDispatcher = UnconfinedTestDispatcher()
|
||||
private val testScope = TestScope(unconfinedTestDispatcher)
|
||||
|
||||
private val tasksRepository = FakeTasksRepository()
|
||||
private val sut = GetTaskUseCase(repository = tasksRepository)
|
||||
private val timersRepository = FakeAppTimersRepository()
|
||||
private val getRemainingAppTimerDurationUseCase =
|
||||
spy(GetRemainingAppTimerDurationUseCase(timersRepository))
|
||||
private val sut =
|
||||
GetTaskUseCase(
|
||||
tasksRepository = tasksRepository,
|
||||
getRemainingAppTimerDurationUseCase = getRemainingAppTimerDurationUseCase,
|
||||
)
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
tasksRepository.seedTasks(listOf(TASK_1))
|
||||
timersRepository.setTimer(PACKAGE_1, UserHandle(USER_1), REMAINING_APP_DURATION)
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_ENABLE_REFACTOR_DIGITAL_WELLBEING_TOAST)
|
||||
fun taskNotSeeded_returnsNull() =
|
||||
testScope.runTest {
|
||||
val result = sut.invoke(NOT_FOUND_TASK_ID).firstOrNull()
|
||||
|
||||
assertThat(result).isNull()
|
||||
verify(getRemainingAppTimerDurationUseCase, times(0))
|
||||
.invoke(anyString(), any<UserHandle>())
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_ENABLE_REFACTOR_DIGITAL_WELLBEING_TOAST)
|
||||
fun taskNotVisible_returnsNull() =
|
||||
testScope.runTest {
|
||||
val result = sut.invoke(TASK_1_ID).firstOrNull()
|
||||
|
||||
assertThat(result).isNull()
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_ENABLE_REFACTOR_DIGITAL_WELLBEING_TOAST)
|
||||
fun taskVisible_returnsData() =
|
||||
testScope.runTest {
|
||||
tasksRepository.setVisibleTasks(setOf(TASK_1_ID))
|
||||
val expectedResult =
|
||||
TaskModel(
|
||||
id = TASK_1_ID,
|
||||
title = "Title $TASK_1_ID",
|
||||
titleDescription = "Content Description $TASK_1_ID",
|
||||
icon = TASK_1_ICON,
|
||||
thumbnail = null,
|
||||
backgroundColor = Color.BLACK,
|
||||
isLocked = false,
|
||||
)
|
||||
tasksRepository.setVisibleTasks(DEFAULT_DISPLAY, setOf(TASK_1_ID))
|
||||
|
||||
val result = sut.invoke(TASK_1_ID).firstOrNull()
|
||||
assertThat(result).isEqualTo(expectedResult)
|
||||
|
||||
assertThat(result)
|
||||
.isEqualTo(
|
||||
TaskModel(
|
||||
id = TASK_1_ID,
|
||||
packageName = PACKAGE_1,
|
||||
title = "Title $TASK_1_ID",
|
||||
titleDescription = "Content Description $TASK_1_ID",
|
||||
icon = TASK_1_ICON,
|
||||
thumbnail = null,
|
||||
backgroundColor = Color.BLACK,
|
||||
isLocked = false,
|
||||
isMinimized = false,
|
||||
remainingAppDuration = ROUNDED_REMAINING_APP_DURATION,
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_ENABLE_REFACTOR_DIGITAL_WELLBEING_TOAST)
|
||||
fun taskVisible_noAppTimer_returnsDataWithoutTimer() =
|
||||
testScope.runTest {
|
||||
tasksRepository.setVisibleTasks(DEFAULT_DISPLAY, setOf(TASK_1_ID))
|
||||
timersRepository.resetTimer(PACKAGE_1, UserHandle(USER_1))
|
||||
|
||||
val result = sut.invoke(TASK_1_ID).firstOrNull()
|
||||
|
||||
assertThat(result)
|
||||
.isEqualTo(
|
||||
TaskModel(
|
||||
id = TASK_1_ID,
|
||||
packageName = PACKAGE_1,
|
||||
title = "Title $TASK_1_ID",
|
||||
titleDescription = "Content Description $TASK_1_ID",
|
||||
icon = TASK_1_ICON,
|
||||
thumbnail = null,
|
||||
backgroundColor = Color.BLACK,
|
||||
isLocked = false,
|
||||
isMinimized = false,
|
||||
remainingAppDuration = null,
|
||||
)
|
||||
)
|
||||
verify(getRemainingAppTimerDurationUseCase, times(1))
|
||||
.invoke(anyString(), any<UserHandle>())
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(Flags.FLAG_ENABLE_REFACTOR_DIGITAL_WELLBEING_TOAST)
|
||||
fun taskVisible_dwbFlagOff_doesNotFetchTimer() =
|
||||
testScope.runTest {
|
||||
tasksRepository.setVisibleTasks(DEFAULT_DISPLAY, setOf(TASK_1_ID))
|
||||
|
||||
val result = sut.invoke(TASK_1_ID).firstOrNull()
|
||||
|
||||
assertThat(result)
|
||||
.isEqualTo(
|
||||
TaskModel(
|
||||
id = TASK_1_ID,
|
||||
packageName = PACKAGE_1,
|
||||
title = "Title $TASK_1_ID",
|
||||
titleDescription = "Content Description $TASK_1_ID",
|
||||
icon = TASK_1_ICON,
|
||||
thumbnail = null,
|
||||
backgroundColor = Color.BLACK,
|
||||
isLocked = false,
|
||||
isMinimized = false,
|
||||
remainingAppDuration = null,
|
||||
)
|
||||
)
|
||||
verify(getRemainingAppTimerDurationUseCase, times(0))
|
||||
.invoke(anyString(), any<UserHandle>())
|
||||
}
|
||||
|
||||
private companion object {
|
||||
const val NOT_FOUND_TASK_ID = 404
|
||||
private const val TASK_1_ID = 1
|
||||
private const val PACKAGE_1 = "com.test.1"
|
||||
private const val USER_1 = 1
|
||||
private val TASK_1_ICON = ShapeDrawable()
|
||||
private val REMAINING_APP_DURATION = Duration.ofHours(2).plusMillis(10)
|
||||
private val ROUNDED_REMAINING_APP_DURATION = Duration.ofHours(2).plusMinutes(1)
|
||||
private val TASK_1 =
|
||||
Task(
|
||||
Task.TaskKey(
|
||||
@@ -91,7 +187,7 @@ class GetTaskUseCaseTest {
|
||||
/* windowingMode = */ 0,
|
||||
/* intent = */ Intent(),
|
||||
/* sourceComponent = */ ComponentName("", ""),
|
||||
/* userId = */ 0,
|
||||
/* userId = */ USER_1,
|
||||
/* lastActiveTime = */ 2000,
|
||||
)
|
||||
)
|
||||
@@ -102,6 +198,8 @@ class GetTaskUseCaseTest {
|
||||
icon = TASK_1_ICON
|
||||
thumbnail = null
|
||||
isLocked = false
|
||||
isMinimized = false
|
||||
topActivity = ComponentName(PACKAGE_1, "SomeClass")
|
||||
}
|
||||
}
|
||||
}
|
||||
+177
-112
@@ -19,55 +19,49 @@ package com.android.quickstep.recents.ui.mapper
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.ShapeDrawable
|
||||
import android.platform.test.annotations.DisableFlags
|
||||
import android.platform.test.annotations.EnableFlags
|
||||
import android.platform.test.flag.junit.SetFlagsRule
|
||||
import android.view.Surface
|
||||
import android.view.View
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import com.android.launcher3.Flags
|
||||
import com.android.launcher3.R
|
||||
import com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_BOTTOM_OR_RIGHT
|
||||
import com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT
|
||||
import com.android.quickstep.recents.ui.viewmodel.TaskData
|
||||
import com.android.quickstep.task.apptimer.TaskAppTimerUiState
|
||||
import com.android.quickstep.task.thumbnail.TaskHeaderUiState
|
||||
import com.android.quickstep.task.thumbnail.TaskThumbnailUiState
|
||||
import com.android.quickstep.task.thumbnail.TaskThumbnailUiState.LiveTile
|
||||
import com.android.quickstep.task.thumbnail.TaskThumbnailUiState.Snapshot
|
||||
import com.android.quickstep.task.thumbnail.TaskThumbnailUiState.ThumbnailHeader
|
||||
import com.android.systemui.shared.recents.model.ThumbnailData
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import java.time.Duration
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class TaskUiStateMapperTest {
|
||||
|
||||
@get:Rule val mSetFlagsRule = SetFlagsRule()
|
||||
|
||||
/** TaskHeaderUiState */
|
||||
@Test
|
||||
fun taskData_isNull_returns_Uninitialized() {
|
||||
fun taskData_isNull_returns_HideHeader() {
|
||||
val result =
|
||||
TaskUiStateMapper.toTaskThumbnailUiState(
|
||||
TaskUiStateMapper.toTaskHeaderState(
|
||||
taskData = null,
|
||||
isLiveTile = false,
|
||||
hasHeader = false,
|
||||
clickCloseListener = null,
|
||||
)
|
||||
assertThat(result).isEqualTo(TaskThumbnailUiState.Uninitialized)
|
||||
assertThat(result).isEqualTo(TaskHeaderUiState.HideHeader)
|
||||
}
|
||||
|
||||
@DisableFlags(Flags.FLAG_ENABLE_DESKTOP_EXPLODED_VIEW)
|
||||
@Test
|
||||
fun taskData_isLiveTile_returns_LiveTile() {
|
||||
val inputs =
|
||||
listOf(TASK_DATA, TASK_DATA.copy(thumbnailData = null), TASK_DATA.copy(isLocked = true))
|
||||
inputs.forEach { input ->
|
||||
val result =
|
||||
TaskUiStateMapper.toTaskThumbnailUiState(
|
||||
taskData = input,
|
||||
isLiveTile = true,
|
||||
hasHeader = false,
|
||||
clickCloseListener = null,
|
||||
)
|
||||
assertThat(result).isEqualTo(LiveTile.WithoutHeader)
|
||||
}
|
||||
}
|
||||
|
||||
@EnableFlags(Flags.FLAG_ENABLE_DESKTOP_EXPLODED_VIEW)
|
||||
@Test
|
||||
fun taskData_isLiveTileWithHeader_returns_LiveTileWithHeader() {
|
||||
fun explodedFlagDisabled_returnsHideHeader() {
|
||||
val inputs =
|
||||
listOf(
|
||||
TASK_DATA,
|
||||
@@ -76,15 +70,11 @@ class TaskUiStateMapperTest {
|
||||
TASK_DATA.copy(title = null),
|
||||
)
|
||||
val closeCallback = View.OnClickListener {}
|
||||
val expected =
|
||||
LiveTile.WithHeader(
|
||||
header = ThumbnailHeader(TASK_ICON, TASK_TITLE_DESCRIPTION, closeCallback)
|
||||
)
|
||||
val expected = TaskHeaderUiState.HideHeader
|
||||
inputs.forEach { taskData ->
|
||||
val result =
|
||||
TaskUiStateMapper.toTaskThumbnailUiState(
|
||||
TaskUiStateMapper.toTaskHeaderState(
|
||||
taskData = taskData,
|
||||
isLiveTile = true,
|
||||
hasHeader = true,
|
||||
clickCloseListener = closeCallback,
|
||||
)
|
||||
@@ -94,40 +84,85 @@ class TaskUiStateMapperTest {
|
||||
|
||||
@EnableFlags(Flags.FLAG_ENABLE_DESKTOP_EXPLODED_VIEW)
|
||||
@Test
|
||||
fun taskData_isLiveTileWithHeader_missingHeaderData_returns_LiveTileWithoutHeader() {
|
||||
fun taskData_hasHeader_and_taskData_returnsShowHeader() {
|
||||
val inputs =
|
||||
listOf(
|
||||
TASK_DATA.copy(icon = null),
|
||||
TASK_DATA.copy(titleDescription = null),
|
||||
TASK_DATA.copy(icon = null, titleDescription = null),
|
||||
TASK_DATA.copy(isLiveTile = true),
|
||||
TASK_DATA.copy(isLiveTile = true, thumbnailData = null),
|
||||
TASK_DATA.copy(isLiveTile = true, isLocked = true),
|
||||
TASK_DATA.copy(isLiveTile = true, title = null),
|
||||
)
|
||||
val closeCallback = View.OnClickListener {}
|
||||
val expected =
|
||||
TaskHeaderUiState.ShowHeader(
|
||||
header =
|
||||
TaskHeaderUiState.ThumbnailHeader(
|
||||
TASK_ICON,
|
||||
TASK_TITLE_DESCRIPTION,
|
||||
closeCallback,
|
||||
)
|
||||
)
|
||||
inputs.forEach { taskData ->
|
||||
val result =
|
||||
TaskUiStateMapper.toTaskHeaderState(
|
||||
taskData = taskData,
|
||||
hasHeader = true,
|
||||
clickCloseListener = closeCallback,
|
||||
)
|
||||
assertThat(result).isEqualTo(expected)
|
||||
}
|
||||
}
|
||||
|
||||
@EnableFlags(Flags.FLAG_ENABLE_DESKTOP_EXPLODED_VIEW)
|
||||
@Test
|
||||
fun taskData_hasHeader_emptyTaskData_returns_HideHeader() {
|
||||
val inputs =
|
||||
listOf(
|
||||
TASK_DATA.copy(isLiveTile = true, icon = null),
|
||||
TASK_DATA.copy(isLiveTile = true, titleDescription = null),
|
||||
TASK_DATA.copy(isLiveTile = true, icon = null, titleDescription = null),
|
||||
)
|
||||
|
||||
inputs.forEach { taskData ->
|
||||
val result =
|
||||
TaskUiStateMapper.toTaskThumbnailUiState(
|
||||
TaskUiStateMapper.toTaskHeaderState(
|
||||
taskData = taskData,
|
||||
isLiveTile = true,
|
||||
hasHeader = true,
|
||||
clickCloseListener = {},
|
||||
)
|
||||
assertThat(result).isEqualTo(LiveTile.WithoutHeader)
|
||||
assertThat(result).isEqualTo(TaskHeaderUiState.HideHeader)
|
||||
}
|
||||
}
|
||||
|
||||
/** TaskThumbnailUiState */
|
||||
@Test
|
||||
fun taskData_isNull_returns_Uninitialized() {
|
||||
val result = TaskUiStateMapper.toTaskThumbnailUiState(taskData = null)
|
||||
assertThat(result).isEqualTo(TaskThumbnailUiState.Uninitialized)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun taskData_isLiveTile_returns_LiveTile() {
|
||||
val inputs =
|
||||
listOf(
|
||||
TASK_DATA.copy(isLiveTile = true),
|
||||
TASK_DATA.copy(isLiveTile = true, thumbnailData = null),
|
||||
TASK_DATA.copy(isLiveTile = true, isLocked = true),
|
||||
)
|
||||
inputs.forEach { input ->
|
||||
val result = TaskUiStateMapper.toTaskThumbnailUiState(taskData = input)
|
||||
assertThat(result).isEqualTo(LiveTile)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun taskData_isStaticTile_returns_SnapshotSplash() {
|
||||
val result =
|
||||
TaskUiStateMapper.toTaskThumbnailUiState(
|
||||
taskData = TASK_DATA,
|
||||
isLiveTile = false,
|
||||
hasHeader = false,
|
||||
clickCloseListener = null,
|
||||
)
|
||||
val result = TaskUiStateMapper.toTaskThumbnailUiState(taskData = TASK_DATA)
|
||||
|
||||
val expected =
|
||||
TaskThumbnailUiState.SnapshotSplash(
|
||||
snapshot =
|
||||
Snapshot.WithoutHeader(
|
||||
Snapshot(
|
||||
backgroundColor = TASK_BACKGROUND_COLOR,
|
||||
bitmap = TASK_THUMBNAIL,
|
||||
thumbnailRotation = Surface.ROTATION_0,
|
||||
@@ -138,72 +173,11 @@ class TaskUiStateMapperTest {
|
||||
assertThat(result).isEqualTo(expected)
|
||||
}
|
||||
|
||||
@EnableFlags(Flags.FLAG_ENABLE_DESKTOP_EXPLODED_VIEW)
|
||||
@Test
|
||||
fun taskData_isStaticTile_withHeader_returns_SnapshotSplashWithHeader() {
|
||||
val inputs = listOf(TASK_DATA, TASK_DATA.copy(title = null))
|
||||
val closeCallback = View.OnClickListener {}
|
||||
val expected =
|
||||
TaskThumbnailUiState.SnapshotSplash(
|
||||
snapshot =
|
||||
Snapshot.WithHeader(
|
||||
backgroundColor = TASK_BACKGROUND_COLOR,
|
||||
bitmap = TASK_THUMBNAIL,
|
||||
thumbnailRotation = Surface.ROTATION_0,
|
||||
header = ThumbnailHeader(TASK_ICON, TASK_TITLE_DESCRIPTION, closeCallback),
|
||||
),
|
||||
splash = TASK_ICON,
|
||||
)
|
||||
inputs.forEach { taskData ->
|
||||
val result =
|
||||
TaskUiStateMapper.toTaskThumbnailUiState(
|
||||
taskData = taskData,
|
||||
isLiveTile = false,
|
||||
hasHeader = true,
|
||||
clickCloseListener = closeCallback,
|
||||
)
|
||||
assertThat(result).isEqualTo(expected)
|
||||
}
|
||||
}
|
||||
|
||||
@EnableFlags(Flags.FLAG_ENABLE_DESKTOP_EXPLODED_VIEW)
|
||||
@Test
|
||||
fun taskData_isStaticTile_missingHeaderData_returns_SnapshotSplashWithoutHeader() {
|
||||
val inputs =
|
||||
listOf(
|
||||
TASK_DATA.copy(titleDescription = null, icon = null),
|
||||
TASK_DATA.copy(titleDescription = null),
|
||||
TASK_DATA.copy(icon = null),
|
||||
)
|
||||
val expected =
|
||||
Snapshot.WithoutHeader(
|
||||
backgroundColor = TASK_BACKGROUND_COLOR,
|
||||
thumbnailRotation = Surface.ROTATION_0,
|
||||
bitmap = TASK_THUMBNAIL,
|
||||
)
|
||||
inputs.forEach { taskData ->
|
||||
val result =
|
||||
TaskUiStateMapper.toTaskThumbnailUiState(
|
||||
taskData = taskData,
|
||||
isLiveTile = false,
|
||||
hasHeader = true,
|
||||
clickCloseListener = {},
|
||||
)
|
||||
|
||||
assertThat(result).isInstanceOf(TaskThumbnailUiState.SnapshotSplash::class.java)
|
||||
result as TaskThumbnailUiState.SnapshotSplash
|
||||
assertThat(result.snapshot).isEqualTo(expected)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun taskData_thumbnailIsNull_returns_BackgroundOnly() {
|
||||
val result =
|
||||
TaskUiStateMapper.toTaskThumbnailUiState(
|
||||
taskData = TASK_DATA.copy(thumbnailData = null),
|
||||
isLiveTile = false,
|
||||
hasHeader = false,
|
||||
clickCloseListener = null,
|
||||
taskData = TASK_DATA.copy(thumbnailData = null)
|
||||
)
|
||||
|
||||
val expected = TaskThumbnailUiState.BackgroundOnly(TASK_BACKGROUND_COLOR)
|
||||
@@ -213,34 +187,125 @@ class TaskUiStateMapperTest {
|
||||
@Test
|
||||
fun taskData_isLocked_returns_BackgroundOnly() {
|
||||
val result =
|
||||
TaskUiStateMapper.toTaskThumbnailUiState(
|
||||
taskData = TASK_DATA.copy(isLocked = true),
|
||||
isLiveTile = false,
|
||||
hasHeader = false,
|
||||
clickCloseListener = null,
|
||||
)
|
||||
TaskUiStateMapper.toTaskThumbnailUiState(taskData = TASK_DATA.copy(isLocked = true))
|
||||
|
||||
val expected = TaskThumbnailUiState.BackgroundOnly(TASK_BACKGROUND_COLOR)
|
||||
assertThat(result).isEqualTo(expected)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun toTaskAppTimer_nullTaskData_returnsUninitialized() {
|
||||
val result =
|
||||
TaskUiStateMapper.toTaskAppTimerUiState(
|
||||
canShowAppTimer = true,
|
||||
stagePosition = STAGE_POSITION_DEFAULT,
|
||||
taskData = null,
|
||||
)
|
||||
|
||||
val expected = TaskAppTimerUiState.Uninitialized
|
||||
assertThat(result).isEqualTo(expected)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun toTaskAppTimer_noTaskData_returnsUninitialized() {
|
||||
val result =
|
||||
TaskUiStateMapper.toTaskAppTimerUiState(
|
||||
canShowAppTimer = true,
|
||||
stagePosition = STAGE_POSITION_DEFAULT,
|
||||
taskData = TaskData.NoData(TASK_ID),
|
||||
)
|
||||
|
||||
val expected = TaskAppTimerUiState.Uninitialized
|
||||
assertThat(result).isEqualTo(expected)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun toTaskAppTimer_canShowAppTimerFalse_returnsNoTimer() {
|
||||
val result =
|
||||
TaskUiStateMapper.toTaskAppTimerUiState(
|
||||
canShowAppTimer = false,
|
||||
stagePosition = STAGE_POSITION_DEFAULT,
|
||||
taskData = TASK_DATA,
|
||||
)
|
||||
|
||||
val expected = TaskAppTimerUiState.NoTimer(taskDescription = TASK_TITLE_DESCRIPTION)
|
||||
assertThat(result).isEqualTo(expected)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun toTaskAppTimer_timerNullAndCanShow_returnsNoTimer() {
|
||||
val result =
|
||||
TaskUiStateMapper.toTaskAppTimerUiState(
|
||||
canShowAppTimer = false,
|
||||
stagePosition = STAGE_POSITION_DEFAULT,
|
||||
taskData = TASK_DATA.copy(remainingAppTimerDuration = null),
|
||||
)
|
||||
|
||||
val expected = TaskAppTimerUiState.NoTimer(taskDescription = TASK_TITLE_DESCRIPTION)
|
||||
assertThat(result).isEqualTo(expected)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun toTaskAppTimer_timerPresentAndCanShow_returnsTimer() {
|
||||
val result =
|
||||
TaskUiStateMapper.toTaskAppTimerUiState(
|
||||
canShowAppTimer = true,
|
||||
stagePosition = STAGE_POSITION_DEFAULT,
|
||||
taskData = TASK_DATA.copy(remainingAppTimerDuration = TASK_APP_TIMER_DURATION),
|
||||
)
|
||||
|
||||
val expected =
|
||||
TaskAppTimerUiState.Timer(
|
||||
timeRemaining = TASK_APP_TIMER_DURATION,
|
||||
taskDescription = TASK_DATA.titleDescription,
|
||||
taskPackageName = TASK_DATA.packageName,
|
||||
accessibilityActionId = R.id.action_digital_wellbeing_top_left,
|
||||
)
|
||||
assertThat(result).isEqualTo(expected)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun toTaskAppTimer_stagePositionBottomOrRight_returnsTimerWithCorrectActionId() {
|
||||
val result =
|
||||
TaskUiStateMapper.toTaskAppTimerUiState(
|
||||
canShowAppTimer = true,
|
||||
stagePosition = STAGE_POSITION_BOTTOM_OR_RIGHT,
|
||||
taskData = TASK_DATA.copy(remainingAppTimerDuration = TASK_APP_TIMER_DURATION),
|
||||
)
|
||||
|
||||
val expected =
|
||||
TaskAppTimerUiState.Timer(
|
||||
timeRemaining = TASK_APP_TIMER_DURATION,
|
||||
taskDescription = TASK_DATA.titleDescription,
|
||||
taskPackageName = TASK_DATA.packageName,
|
||||
accessibilityActionId = R.id.action_digital_wellbeing_bottom_right,
|
||||
)
|
||||
assertThat(result).isEqualTo(expected)
|
||||
}
|
||||
|
||||
private companion object {
|
||||
const val TASK_TITLE_DESCRIPTION = "Title Description 1"
|
||||
var TASK_ID = 1
|
||||
var PACKAGE_NAME = "com.test"
|
||||
val TASK_ICON = ShapeDrawable()
|
||||
val TASK_THUMBNAIL = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888)
|
||||
val TASK_THUMBNAIL_DATA =
|
||||
ThumbnailData(thumbnail = TASK_THUMBNAIL, rotation = Surface.ROTATION_0)
|
||||
val TASK_BACKGROUND_COLOR = Color.rgb(1, 2, 3)
|
||||
val TASK_APP_TIMER_DURATION: Duration = Duration.ofMillis(30)
|
||||
val STAGE_POSITION_DEFAULT = STAGE_POSITION_TOP_OR_LEFT
|
||||
val TASK_DATA =
|
||||
TaskData.Data(
|
||||
TASK_ID,
|
||||
packageName = PACKAGE_NAME,
|
||||
title = "Task 1",
|
||||
titleDescription = TASK_TITLE_DESCRIPTION,
|
||||
icon = TASK_ICON,
|
||||
thumbnailData = TASK_THUMBNAIL_DATA,
|
||||
backgroundColor = TASK_BACKGROUND_COLOR,
|
||||
isLocked = false,
|
||||
isLiveTile = false,
|
||||
remainingAppTimerDuration = TASK_APP_TIMER_DURATION,
|
||||
)
|
||||
}
|
||||
}
|
||||
+82
-14
@@ -35,6 +35,7 @@ import com.android.quickstep.recents.viewmodel.RecentsViewData
|
||||
import com.android.quickstep.views.TaskViewType
|
||||
import com.android.systemui.shared.recents.model.ThumbnailData
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import java.time.Duration
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.coroutines.flow.flow
|
||||
@@ -70,6 +71,8 @@ class TaskViewModelTest {
|
||||
whenever(getTaskUseCase.invoke(TASK_MODEL_1.id)).thenReturn(flow { emit(TASK_MODEL_1) })
|
||||
whenever(getTaskUseCase.invoke(TASK_MODEL_2.id)).thenReturn(flow { emit(TASK_MODEL_2) })
|
||||
whenever(getTaskUseCase.invoke(TASK_MODEL_3.id)).thenReturn(flow { emit(TASK_MODEL_3) })
|
||||
whenever(getTaskUseCase.invoke(TASK_MODEL_MINIMIZED.id))
|
||||
.thenReturn(flow { emit(TASK_MODEL_MINIMIZED) })
|
||||
whenever(getTaskUseCase.invoke(INVALID_TASK_ID)).thenReturn(flow { emit(null) })
|
||||
recentsViewData.runningTaskIds.value = emptySet()
|
||||
}
|
||||
@@ -81,7 +84,6 @@ class TaskViewModelTest {
|
||||
val expectedResult =
|
||||
TaskTileUiState(
|
||||
tasks = listOf(TASK_MODEL_1.toUiState()),
|
||||
isLiveTile = false,
|
||||
hasHeader = false,
|
||||
sysUiStatusNavFlags = FLAGS_APPEARANCE_LIGHT_THEME,
|
||||
taskOverlayEnabled = false,
|
||||
@@ -129,7 +131,6 @@ class TaskViewModelTest {
|
||||
TASK_MODEL_3.toUiState(),
|
||||
TaskData.NoData(INVALID_TASK_ID),
|
||||
),
|
||||
isLiveTile = false,
|
||||
hasHeader = false,
|
||||
sysUiStatusNavFlags = FLAGS_APPEARANCE_LIGHT_THEME,
|
||||
taskOverlayEnabled = false,
|
||||
@@ -149,11 +150,34 @@ class TaskViewModelTest {
|
||||
TaskTileUiState(
|
||||
tasks =
|
||||
listOf(
|
||||
TASK_MODEL_1.toUiState(),
|
||||
TASK_MODEL_2.toUiState(),
|
||||
TASK_MODEL_3.toUiState(),
|
||||
TASK_MODEL_1.toUiState(isLiveTile = true),
|
||||
TASK_MODEL_2.toUiState(isLiveTile = true),
|
||||
TASK_MODEL_3.toUiState(isLiveTile = true),
|
||||
),
|
||||
hasHeader = false,
|
||||
sysUiStatusNavFlags = FLAGS_APPEARANCE_LIGHT_THEME,
|
||||
taskOverlayEnabled = false,
|
||||
isCentralTask = false,
|
||||
)
|
||||
assertThat(sut.state.first()).isEqualTo(expectedResult)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun isMixedLiveTile_when_oneTaskIsMinimized() =
|
||||
testScope.runTest {
|
||||
recentsViewData.runningTaskShowScreenshot.value = false
|
||||
recentsViewData.runningTaskIds.value =
|
||||
setOf(TASK_MODEL_1.id, TASK_MODEL_2.id, TASK_MODEL_3.id, TASK_MODEL_MINIMIZED.id)
|
||||
sut.bind(TASK_MODEL_1.id, TASK_MODEL_2.id, TASK_MODEL_3.id, TASK_MODEL_MINIMIZED.id)
|
||||
val expectedResult =
|
||||
TaskTileUiState(
|
||||
tasks =
|
||||
listOf(
|
||||
TASK_MODEL_1.toUiState(isLiveTile = true),
|
||||
TASK_MODEL_2.toUiState(isLiveTile = true),
|
||||
TASK_MODEL_3.toUiState(isLiveTile = true),
|
||||
TASK_MODEL_MINIMIZED.toUiState(isLiveTile = false),
|
||||
),
|
||||
isLiveTile = true,
|
||||
hasHeader = false,
|
||||
sysUiStatusNavFlags = FLAGS_APPEARANCE_LIGHT_THEME,
|
||||
taskOverlayEnabled = false,
|
||||
@@ -177,7 +201,6 @@ class TaskViewModelTest {
|
||||
TASK_MODEL_2.toUiState(),
|
||||
TASK_MODEL_3.toUiState(),
|
||||
),
|
||||
isLiveTile = false,
|
||||
hasHeader = false,
|
||||
sysUiStatusNavFlags = FLAGS_APPEARANCE_LIGHT_THEME,
|
||||
taskOverlayEnabled = false,
|
||||
@@ -200,7 +223,6 @@ class TaskViewModelTest {
|
||||
TASK_MODEL_2.toUiState(),
|
||||
TASK_MODEL_3.toUiState(),
|
||||
),
|
||||
isLiveTile = false,
|
||||
hasHeader = false,
|
||||
sysUiStatusNavFlags = FLAGS_APPEARANCE_LIGHT_THEME,
|
||||
taskOverlayEnabled = false,
|
||||
@@ -219,7 +241,6 @@ class TaskViewModelTest {
|
||||
val expectedResult =
|
||||
TaskTileUiState(
|
||||
tasks = listOf(TASK_MODEL_1.toUiState(), TASK_MODEL_2.toUiState()),
|
||||
isLiveTile = false,
|
||||
hasHeader = false,
|
||||
sysUiStatusNavFlags = FLAGS_APPEARANCE_LIGHT_THEME,
|
||||
taskOverlayEnabled = false,
|
||||
@@ -235,7 +256,6 @@ class TaskViewModelTest {
|
||||
val expectedResult =
|
||||
TaskTileUiState(
|
||||
listOf(TaskData.NoData(INVALID_TASK_ID)),
|
||||
isLiveTile = false,
|
||||
hasHeader = false,
|
||||
sysUiStatusNavFlags = FLAGS_APPEARANCE_DEFAULT,
|
||||
taskOverlayEnabled = false,
|
||||
@@ -274,6 +294,28 @@ class TaskViewModelTest {
|
||||
assertThat(sut.state.first().taskOverlayEnabled).isFalse()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun taskOverlayDisabled_when_OverlayIsEnabledForVisibleDesktopTask() =
|
||||
testScope.runTest {
|
||||
sut = createTaskViewModel(TaskViewType.DESKTOP)
|
||||
sut.bind(TASK_MODEL_1.id)
|
||||
recentsViewData.overlayEnabled.value = true
|
||||
recentsViewData.settledFullyVisibleTaskIds.value = setOf(1)
|
||||
|
||||
assertThat(sut.state.first().taskOverlayEnabled).isFalse()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun taskOverlayDisabled_when_OverlayIsEnabledForVisibleGroupedTask() =
|
||||
testScope.runTest {
|
||||
sut = createTaskViewModel(TaskViewType.GROUPED)
|
||||
sut.bind(TASK_MODEL_1.id)
|
||||
recentsViewData.overlayEnabled.value = true
|
||||
recentsViewData.settledFullyVisibleTaskIds.value = setOf(1)
|
||||
|
||||
assertThat(sut.state.first().taskOverlayEnabled).isFalse()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun isCentralTask_when_CentralTaskIdsMatchTaskIds() =
|
||||
testScope.runTest {
|
||||
@@ -298,15 +340,18 @@ class TaskViewModelTest {
|
||||
verify(isThumbnailValidUseCase).invoke(anyOrNull(), anyInt(), anyInt())
|
||||
}
|
||||
|
||||
private fun TaskModel.toUiState() =
|
||||
private fun TaskModel.toUiState(isLiveTile: Boolean = false) =
|
||||
TaskData.Data(
|
||||
taskId = id,
|
||||
packageName = packageName,
|
||||
title = title,
|
||||
titleDescription = titleDescription,
|
||||
icon = icon!!,
|
||||
thumbnailData = thumbnail,
|
||||
backgroundColor = backgroundColor,
|
||||
isLocked = isLocked,
|
||||
isLiveTile = isLiveTile,
|
||||
remainingAppTimerDuration = remainingAppDuration,
|
||||
)
|
||||
|
||||
private fun createTaskViewModel(taskViewType: TaskViewType) =
|
||||
@@ -321,6 +366,7 @@ class TaskViewModelTest {
|
||||
)
|
||||
|
||||
private companion object {
|
||||
const val PACKAGE_NAME = "com.test"
|
||||
const val INVALID_TASK_ID = -1
|
||||
const val FLAGS_APPEARANCE_LIGHT_THEME = FLAG_LIGHT_STATUS or FLAG_LIGHT_NAV
|
||||
const val FLAGS_APPEARANCE_DEFAULT = 0
|
||||
@@ -332,32 +378,54 @@ class TaskViewModelTest {
|
||||
val TASK_MODEL_1 =
|
||||
TaskModel(
|
||||
1,
|
||||
PACKAGE_NAME,
|
||||
"Title 1",
|
||||
"Content Description 1",
|
||||
ShapeDrawable(),
|
||||
ThumbnailData(appearance = APPEARANCE_LIGHT_THEME),
|
||||
Color.BLACK,
|
||||
false,
|
||||
/* isLocked= */ false,
|
||||
/* isMinimized= */ false,
|
||||
/*remainingAppDuration= */ Duration.ofMillis(30),
|
||||
)
|
||||
val TASK_MODEL_2 =
|
||||
TaskModel(
|
||||
2,
|
||||
PACKAGE_NAME,
|
||||
"Title 2",
|
||||
"Content Description 2",
|
||||
ShapeDrawable(),
|
||||
ThumbnailData(appearance = APPEARANCE_LIGHT_THEME),
|
||||
Color.RED,
|
||||
true,
|
||||
/* isLocked= */ true,
|
||||
/* isMinimized= */ false,
|
||||
/*remainingAppDuration= */ Duration.ofHours(5).plusMinutes(2),
|
||||
)
|
||||
val TASK_MODEL_3 =
|
||||
TaskModel(
|
||||
3,
|
||||
PACKAGE_NAME,
|
||||
"Title 3",
|
||||
"Content Description 3",
|
||||
ShapeDrawable(),
|
||||
ThumbnailData(appearance = APPEARANCE_LIGHT_THEME),
|
||||
Color.BLUE,
|
||||
false,
|
||||
/* isLocked= */ false,
|
||||
/* isMinimized= */ false,
|
||||
/* remainingAppDuration= */ null,
|
||||
)
|
||||
val TASK_MODEL_MINIMIZED =
|
||||
TaskModel(
|
||||
4,
|
||||
PACKAGE_NAME,
|
||||
"Title 4",
|
||||
"Content Description 4",
|
||||
ShapeDrawable(),
|
||||
ThumbnailData(appearance = APPEARANCE_LIGHT_THEME),
|
||||
Color.BLUE,
|
||||
/* isLocked= */ false,
|
||||
/* isMinimized= */ true,
|
||||
/* remainingAppDuration= */ null,
|
||||
)
|
||||
}
|
||||
}
|
||||
+4
-2
@@ -20,6 +20,7 @@ import android.content.ComponentName
|
||||
import android.content.Intent
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.Color
|
||||
import android.view.Display.DEFAULT_DISPLAY
|
||||
import android.view.Surface
|
||||
import com.android.quickstep.recents.data.FakeTasksRepository
|
||||
import com.android.systemui.shared.recents.model.Task
|
||||
@@ -34,7 +35,8 @@ import org.mockito.kotlin.whenever
|
||||
class RecentsViewModelTest {
|
||||
private val tasksRepository = FakeTasksRepository()
|
||||
private val recentsViewData = RecentsViewData()
|
||||
private val systemUnderTest = RecentsViewModel(tasksRepository, recentsViewData)
|
||||
private val systemUnderTest =
|
||||
RecentsViewModel(tasksRepository, recentsViewData, DEFAULT_DISPLAY)
|
||||
|
||||
private val tasks = (0..5).map(::createTaskWithId)
|
||||
|
||||
@@ -97,7 +99,7 @@ class RecentsViewModelTest {
|
||||
)
|
||||
// setVisibleTasks forces FakeTasksRepository to update the flows returned by
|
||||
// getThumbnailById
|
||||
tasksRepository.setVisibleTasks(setOf(1, 2))
|
||||
tasksRepository.setVisibleTasks(DEFAULT_DISPLAY, setOf(1, 2))
|
||||
|
||||
// Then wait for thumbnailData should complete, and the previous getThumbnailById flow
|
||||
// should return updated values
|
||||
|
||||
+21
-9
@@ -76,6 +76,19 @@ class TaskbarPinningControllerTest : TaskbarBaseTestCase() {
|
||||
)
|
||||
)
|
||||
.thenAnswer { _ -> isInDesktopMode }
|
||||
whenever(
|
||||
taskbarControllers.taskbarDesktopModeController.isInDesktopMode(
|
||||
taskbarActivityContext.displayId
|
||||
)
|
||||
)
|
||||
.thenAnswer { _ -> isInDesktopMode }
|
||||
whenever(
|
||||
taskbarControllers.taskbarDesktopModeController.shouldShowDesktopTasksInTaskbar(
|
||||
taskbarActivityContext.displayId
|
||||
)
|
||||
)
|
||||
.thenAnswer { _ -> isInDesktopMode }
|
||||
|
||||
pinningController = spy(TaskbarPinningController(taskbarActivityContext))
|
||||
pinningController.init(taskbarControllers, taskbarSharedState)
|
||||
}
|
||||
@@ -117,6 +130,14 @@ class TaskbarPinningControllerTest : TaskbarBaseTestCase() {
|
||||
verify(pinningController, times(1)).animateTaskbarPinning(PINNING_PERSISTENT)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testOnCloseCallback_whenLauncherPreferenceChanged_shouldNotAnimateToTaskbarInDesktopMode() {
|
||||
isInDesktopMode = true
|
||||
whenever(launcherPrefs.get(TASKBAR_PINNING_IN_DESKTOP_MODE)).thenReturn(false)
|
||||
pinningController.onCloseCallback(true)
|
||||
verify(pinningController, never()).animateTaskbarPinning(any())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testOnCloseCallback_whenLauncherPreferenceChanged_shouldAnimateToTransientTaskbar() {
|
||||
whenever(launcherPrefs.get(TASKBAR_PINNING)).thenReturn(true)
|
||||
@@ -211,13 +232,4 @@ class TaskbarPinningControllerTest : TaskbarBaseTestCase() {
|
||||
assertThat(pinningController.isAnimatingTaskbarPinning).isFalse()
|
||||
verify(launcherPrefs, times(1)).put(TASKBAR_PINNING, true)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testRecreateTaskbarAndUpdatePinningValue_whenAnimationEnds_shouldUpdateTaskbarPinningDesktopModePref() {
|
||||
isInDesktopMode = true
|
||||
pinningController.recreateTaskbarAndUpdatePinningValue()
|
||||
verify(taskbarDragLayer, times(1)).setAnimatingTaskbarPinning(false)
|
||||
assertThat(pinningController.isAnimatingTaskbarPinning).isFalse()
|
||||
verify(launcherPrefs, times(1)).put(TASKBAR_PINNING_IN_DESKTOP_MODE, true)
|
||||
}
|
||||
}
|
||||
-11
@@ -52,7 +52,6 @@ import com.android.quickstep.BaseContainerInterface;
|
||||
import com.android.quickstep.DeviceConfigWrapper;
|
||||
import com.android.quickstep.SystemUiProxy;
|
||||
import com.android.quickstep.TopTaskTracker;
|
||||
import com.android.quickstep.orientation.RecentsPagedOrientationHandler;
|
||||
import com.android.quickstep.views.RecentsView;
|
||||
import com.android.quickstep.views.RecentsViewContainer;
|
||||
|
||||
@@ -83,7 +82,6 @@ public class ContextualSearchInvokerTest {
|
||||
private @Mock BaseContainerInterface mMockContainerInterface;
|
||||
private @Mock RecentsViewContainer mMockRecentsViewContainer;
|
||||
private @Mock RecentsView mMockRecentsView;
|
||||
private @Mock RecentsPagedOrientationHandler mMockOrientationHandler;
|
||||
private ContextualSearchInvoker mContextualSearchInvoker;
|
||||
|
||||
@Before
|
||||
@@ -191,15 +189,6 @@ public class ContextualSearchInvokerTest {
|
||||
verify(mMockStatsLogger).log(LAUNCHER_LAUNCH_OMNI_ATTEMPTED_SPLITSCREEN);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runContextualSearchInvocationChecksAndLogFailures_isFakeLandscape() {
|
||||
when(mMockRecentsView.getPagedOrientationHandler()).thenReturn(mMockOrientationHandler);
|
||||
when(mMockOrientationHandler.isLayoutNaturalToLauncher()).thenReturn(false);
|
||||
assertFalse("Expect invocation checks to fail in fake landscape.",
|
||||
mContextualSearchInvoker.runContextualSearchInvocationChecksAndLogFailures());
|
||||
verifyNoMoreInteractions(mMockStatsLogManager);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void invokeContextualSearchUncheckedWithHaptic_cssIsAvailable_commitHapticEnabled() {
|
||||
try (AutoCloseable flag = overrideSearchHapticCommitFlag(true)) {
|
||||
|
||||
+2
-2
@@ -131,7 +131,7 @@ class GestureExclusionManagerTest {
|
||||
}
|
||||
|
||||
private fun awaitTasksCompleted() {
|
||||
Executors.UI_HELPER_EXECUTOR.submit<Any> { null }.get()
|
||||
Executors.MAIN_EXECUTOR.submit<Any> { null }.get()
|
||||
Executors.UI_HELPER_EXECUTOR.submit<Any?> { null }.get()
|
||||
Executors.MAIN_EXECUTOR.submit<Any?> { null }.get()
|
||||
}
|
||||
}
|
||||
@@ -20,9 +20,11 @@ import android.content.ComponentName
|
||||
import android.content.Intent
|
||||
import android.graphics.Rect
|
||||
import android.view.Display.DEFAULT_DISPLAY
|
||||
import android.view.Display.INVALID_DISPLAY
|
||||
import com.android.launcher3.util.LauncherMultivalentJUnit
|
||||
import com.android.launcher3.util.SplitConfigurationOptions
|
||||
import com.android.systemui.shared.recents.model.Task
|
||||
import com.android.wm.shell.shared.split.SplitBounds
|
||||
import com.android.wm.shell.shared.split.SplitScreenConstants
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import org.junit.Test
|
||||
@@ -61,7 +63,7 @@ class GroupTaskTest {
|
||||
@Test
|
||||
fun testGroupTask_equalSplitTasks_isEqual() {
|
||||
val splitBounds =
|
||||
SplitConfigurationOptions.SplitBounds(
|
||||
SplitBounds(
|
||||
Rect(),
|
||||
Rect(),
|
||||
1,
|
||||
@@ -76,7 +78,7 @@ class GroupTaskTest {
|
||||
@Test
|
||||
fun testGroupTask_differentSplitTasks_isNotEqual() {
|
||||
val splitBounds1 =
|
||||
SplitConfigurationOptions.SplitBounds(
|
||||
SplitBounds(
|
||||
Rect(),
|
||||
Rect(),
|
||||
1,
|
||||
@@ -84,7 +86,7 @@ class GroupTaskTest {
|
||||
SplitScreenConstants.SNAP_TO_2_50_50,
|
||||
)
|
||||
val splitBounds2 =
|
||||
SplitConfigurationOptions.SplitBounds(
|
||||
SplitBounds(
|
||||
Rect(),
|
||||
Rect(),
|
||||
1,
|
||||
@@ -103,7 +105,86 @@ class GroupTaskTest {
|
||||
assertThat(task1).isNotEqualTo(task2)
|
||||
}
|
||||
|
||||
private fun createTask(id: Int): Task {
|
||||
return Task(Task.TaskKey(id, 0, Intent(), ComponentName("", ""), 0, 0))
|
||||
@Test
|
||||
fun testDesktopTask_matchesDisplayId() {
|
||||
val task1 = DesktopTask(deskId = 0, DEFAULT_DISPLAY, listOf(createTask(1, INVALID_DISPLAY)))
|
||||
assertThat(task1.matchesDisplayId(DEFAULT_DISPLAY)).isTrue()
|
||||
assertThat(task1.matchesDisplayId(DISPLAY_2)).isFalse()
|
||||
val task2 = DesktopTask(deskId = 0, DISPLAY_2, listOf(createTask(1, DISPLAY_2)))
|
||||
assertThat(task2.matchesDisplayId(DEFAULT_DISPLAY)).isFalse()
|
||||
assertThat(task2.matchesDisplayId(DISPLAY_2)).isTrue()
|
||||
val task3 = DesktopTask(deskId = 0, DISPLAY_2, listOf(createTask(1, INVALID_DISPLAY)))
|
||||
assertThat(task3.matchesDisplayId(DEFAULT_DISPLAY)).isFalse()
|
||||
assertThat(task3.matchesDisplayId(DISPLAY_2)).isTrue()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testSingleTask_matchesDisplayId() {
|
||||
val task1 = SingleTask(createTask(1, INVALID_DISPLAY))
|
||||
assertThat(task1.matchesDisplayId(DEFAULT_DISPLAY)).isTrue()
|
||||
assertThat(task1.matchesDisplayId(DISPLAY_2)).isFalse()
|
||||
val task2 = SingleTask(createTask(1, DISPLAY_2))
|
||||
assertThat(task2.matchesDisplayId(DEFAULT_DISPLAY)).isFalse()
|
||||
assertThat(task2.matchesDisplayId(DISPLAY_2)).isTrue()
|
||||
val task3 = SingleTask(createTask(1, DEFAULT_DISPLAY))
|
||||
assertThat(task3.matchesDisplayId(DEFAULT_DISPLAY)).isTrue()
|
||||
assertThat(task3.matchesDisplayId(DISPLAY_2)).isFalse()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testSplitTask_matchesDisplayId() {
|
||||
val splitBounds =
|
||||
SplitBounds(
|
||||
Rect(),
|
||||
Rect(),
|
||||
1,
|
||||
2,
|
||||
SplitScreenConstants.SNAP_TO_2_50_50,
|
||||
)
|
||||
val task1 =
|
||||
SplitTask(createTask(1, INVALID_DISPLAY), createTask(2, INVALID_DISPLAY), splitBounds)
|
||||
assertThat(task1.matchesDisplayId(DEFAULT_DISPLAY)).isTrue()
|
||||
assertThat(task1.matchesDisplayId(DISPLAY_2)).isFalse()
|
||||
val task2 = SplitTask(createTask(1, INVALID_DISPLAY), createTask(2, DISPLAY_2), splitBounds)
|
||||
assertThat(task2.matchesDisplayId(DEFAULT_DISPLAY)).isTrue()
|
||||
assertThat(task2.matchesDisplayId(DISPLAY_2)).isFalse()
|
||||
val task3 = SplitTask(createTask(1, DISPLAY_2), createTask(2, INVALID_DISPLAY), splitBounds)
|
||||
assertThat(task3.matchesDisplayId(DEFAULT_DISPLAY)).isFalse()
|
||||
assertThat(task3.matchesDisplayId(DISPLAY_2)).isTrue()
|
||||
val task4 =
|
||||
SplitTask(createTask(1, DEFAULT_DISPLAY), createTask(2, DEFAULT_DISPLAY), splitBounds)
|
||||
assertThat(task4.matchesDisplayId(DEFAULT_DISPLAY)).isTrue()
|
||||
assertThat(task4.matchesDisplayId(DISPLAY_2)).isFalse()
|
||||
val task5 = SplitTask(createTask(1, DEFAULT_DISPLAY), createTask(2, DISPLAY_2), splitBounds)
|
||||
assertThat(task5.matchesDisplayId(DEFAULT_DISPLAY)).isTrue()
|
||||
assertThat(task5.matchesDisplayId(DISPLAY_2)).isFalse()
|
||||
val task6 = SplitTask(createTask(1, DISPLAY_2), createTask(2, DEFAULT_DISPLAY), splitBounds)
|
||||
assertThat(task6.matchesDisplayId(DEFAULT_DISPLAY)).isFalse()
|
||||
assertThat(task6.matchesDisplayId(DISPLAY_2)).isTrue()
|
||||
}
|
||||
|
||||
private fun createTask(id: Int, displayId: Int = INVALID_DISPLAY, pkg: String? = null): Task {
|
||||
val intent = Intent()
|
||||
pkg.let { intent.setPackage(it) }
|
||||
return Task(
|
||||
Task.TaskKey(
|
||||
id,
|
||||
0,
|
||||
intent,
|
||||
ComponentName(pkg ?: "", ""),
|
||||
0,
|
||||
0,
|
||||
displayId,
|
||||
null,
|
||||
0,
|
||||
false,
|
||||
false,
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val DISPLAY_2 = 2
|
||||
const val PACKAGE = "com.android.launcher3"
|
||||
}
|
||||
}
|
||||
+3
-2
@@ -39,6 +39,7 @@ import com.android.quickstep.util.SplitSelectStateController.SplitFromDesktopCon
|
||||
import com.android.quickstep.views.RecentsView
|
||||
import com.android.quickstep.views.RecentsViewContainer
|
||||
import com.android.systemui.shared.recents.model.Task
|
||||
import com.android.wm.shell.shared.split.SplitBounds
|
||||
import com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_2_50_50
|
||||
import java.util.function.Consumer
|
||||
import org.junit.Assert.assertEquals
|
||||
@@ -663,7 +664,7 @@ class SplitSelectStateControllerTest {
|
||||
return SplitTask(
|
||||
task1,
|
||||
task2,
|
||||
SplitConfigurationOptions.SplitBounds(
|
||||
SplitBounds(
|
||||
/* leftTopBounds = */ Rect(),
|
||||
/* rightBottomBounds = */ Rect(),
|
||||
/* leftTopTaskId = */ task1.key.id,
|
||||
@@ -701,7 +702,7 @@ class SplitSelectStateControllerTest {
|
||||
return SplitTask(
|
||||
task1,
|
||||
task2,
|
||||
SplitConfigurationOptions.SplitBounds(
|
||||
SplitBounds(
|
||||
/* leftTopBounds = */ Rect(),
|
||||
/* rightBottomBounds = */ Rect(),
|
||||
/* leftTopTaskId = */ task1.key.id,
|
||||
|
||||
+11
@@ -786,6 +786,17 @@ class TaskGridNavHelperTest {
|
||||
.isEqualTo(ADD_DESK_PLACEHOLDER_ID)
|
||||
}
|
||||
|
||||
/*
|
||||
5 3 1 |
|
||||
CLEAR_ALL | Invalid ID:
|
||||
6 4 2 | [25] --> [25]
|
||||
*/
|
||||
@Test
|
||||
fun nextGridPage_invalidId_pressTab_noCycle_returnsCurrentPage() {
|
||||
assertThat(getNextGridPage(currentPageTaskViewId = 25, TAB, delta = -1, cycle = false))
|
||||
.isEqualTo(25)
|
||||
}
|
||||
|
||||
// Col offset: 0 1 2
|
||||
// -----------
|
||||
// ID grid: 4 2 0 start
|
||||
|
||||
+63
-66
@@ -40,9 +40,9 @@ import com.android.launcher3.dagger.LauncherAppSingleton;
|
||||
import com.android.launcher3.util.AllModulesMinusWMProxy;
|
||||
import com.android.launcher3.util.DisplayController;
|
||||
import com.android.launcher3.util.DisplayController.Info;
|
||||
import com.android.launcher3.util.LauncherModelHelper;
|
||||
import com.android.launcher3.util.NavigationMode;
|
||||
import com.android.launcher3.util.RotationUtils;
|
||||
import com.android.launcher3.util.SandboxApplication;
|
||||
import com.android.launcher3.util.WindowBounds;
|
||||
import com.android.launcher3.util.window.CachedDisplayInfo;
|
||||
import com.android.launcher3.util.window.WindowManagerProxy;
|
||||
@@ -55,6 +55,7 @@ import dagger.Component;
|
||||
import org.hamcrest.Description;
|
||||
import org.hamcrest.TypeSafeMatcher;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@@ -65,6 +66,8 @@ import java.util.List;
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class TaskViewSimulatorTest {
|
||||
|
||||
@Rule public final SandboxApplication app = new SandboxApplication();
|
||||
|
||||
@Test
|
||||
public void taskProperlyScaled_portrait_noRotation_sameInsets1() {
|
||||
new TaskMatrixVerifier()
|
||||
@@ -123,7 +126,7 @@ public class TaskViewSimulatorTest {
|
||||
.verifyNoTransforms();
|
||||
}
|
||||
|
||||
private static class TaskMatrixVerifier extends TransformParams {
|
||||
private class TaskMatrixVerifier extends TransformParams {
|
||||
|
||||
private Point mDisplaySize = new Point();
|
||||
private int mDensityDpi = DisplayMetrics.DENSITY_DEFAULT;
|
||||
@@ -163,73 +166,67 @@ public class TaskViewSimulatorTest {
|
||||
}
|
||||
|
||||
void verifyNoTransforms() {
|
||||
LauncherModelHelper helper = new LauncherModelHelper();
|
||||
try {
|
||||
DisplayController mockController = mock(DisplayController.class);
|
||||
DisplayController mockController = mock(DisplayController.class);
|
||||
|
||||
helper.sandboxContext.initDaggerComponent(
|
||||
DaggerTaskViewSimulatorTest_TaskViewSimulatorTestComponent.builder()
|
||||
.bindDisplayController(mockController));
|
||||
int rotation = mDisplaySize.x > mDisplaySize.y
|
||||
? Surface.ROTATION_90 : Surface.ROTATION_0;
|
||||
CachedDisplayInfo cdi = new CachedDisplayInfo(mDisplaySize, rotation);
|
||||
WindowBounds wm = new WindowBounds(
|
||||
new Rect(0, 0, mDisplaySize.x, mDisplaySize.y),
|
||||
mDisplayInsets);
|
||||
List<WindowBounds> allBounds = new ArrayList<>(4);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
Rect boundsR = new Rect(wm.bounds);
|
||||
Rect insetsR = new Rect(wm.insets);
|
||||
app.initDaggerComponent(
|
||||
DaggerTaskViewSimulatorTest_TaskViewSimulatorTestComponent.builder()
|
||||
.bindDisplayController(mockController));
|
||||
int rotation = mDisplaySize.x > mDisplaySize.y
|
||||
? Surface.ROTATION_90 : Surface.ROTATION_0;
|
||||
CachedDisplayInfo cdi = new CachedDisplayInfo(mDisplaySize, rotation);
|
||||
WindowBounds wm = new WindowBounds(
|
||||
new Rect(0, 0, mDisplaySize.x, mDisplaySize.y),
|
||||
mDisplayInsets);
|
||||
List<WindowBounds> allBounds = new ArrayList<>(4);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
Rect boundsR = new Rect(wm.bounds);
|
||||
Rect insetsR = new Rect(wm.insets);
|
||||
|
||||
RotationUtils.rotateRect(insetsR, RotationUtils.deltaRotation(rotation, i));
|
||||
RotationUtils.rotateRect(boundsR, RotationUtils.deltaRotation(rotation, i));
|
||||
boundsR.set(0, 0, Math.abs(boundsR.width()), Math.abs(boundsR.height()));
|
||||
allBounds.add(new WindowBounds(boundsR, insetsR));
|
||||
}
|
||||
|
||||
WindowManagerProxy wmProxy = mock(WindowManagerProxy.class);
|
||||
doReturn(cdi).when(wmProxy).getDisplayInfo(any());
|
||||
doReturn(wm).when(wmProxy).getRealBounds(any(), any());
|
||||
doReturn(NavigationMode.NO_BUTTON).when(wmProxy).getNavigationMode(any());
|
||||
|
||||
ArrayMap<CachedDisplayInfo, List<WindowBounds>> perDisplayBoundsCache =
|
||||
new ArrayMap<>();
|
||||
perDisplayBoundsCache.put(cdi.normalize(wmProxy), allBounds);
|
||||
|
||||
Configuration configuration = new Configuration();
|
||||
configuration.densityDpi = mDensityDpi;
|
||||
Context configurationContext = helper.sandboxContext.createConfigurationContext(
|
||||
configuration);
|
||||
|
||||
DisplayController.Info info = new Info(
|
||||
configurationContext, wmProxy, perDisplayBoundsCache);
|
||||
when(mockController.getInfo()).thenReturn(info);
|
||||
|
||||
mDeviceProfile = InvariantDeviceProfile.INSTANCE.get(helper.sandboxContext)
|
||||
.getBestMatch(mAppBounds.width(), mAppBounds.height(), rotation);
|
||||
mDeviceProfile.updateInsets(mLauncherInsets);
|
||||
|
||||
TaskViewSimulator tvs = new TaskViewSimulator(helper.sandboxContext,
|
||||
FallbackActivityInterface.INSTANCE, false, 0);
|
||||
tvs.setDp(mDeviceProfile);
|
||||
|
||||
int launcherRotation = info.rotation;
|
||||
if (mAppRotation < 0) {
|
||||
mAppRotation = launcherRotation;
|
||||
}
|
||||
|
||||
tvs.getOrientationState().update(launcherRotation, mAppRotation);
|
||||
if (mAppInsets == null) {
|
||||
mAppInsets = new Rect(mLauncherInsets);
|
||||
}
|
||||
tvs.setPreviewBounds(mAppBounds, mAppInsets);
|
||||
|
||||
tvs.fullScreenProgress.value = 1;
|
||||
tvs.recentsViewScale.value = tvs.getFullScreenScale();
|
||||
tvs.apply(this);
|
||||
} finally {
|
||||
helper.destroy();
|
||||
RotationUtils.rotateRect(insetsR, RotationUtils.deltaRotation(rotation, i));
|
||||
RotationUtils.rotateRect(boundsR, RotationUtils.deltaRotation(rotation, i));
|
||||
boundsR.set(0, 0, Math.abs(boundsR.width()), Math.abs(boundsR.height()));
|
||||
allBounds.add(new WindowBounds(boundsR, insetsR));
|
||||
}
|
||||
|
||||
WindowManagerProxy wmProxy = mock(WindowManagerProxy.class);
|
||||
doReturn(cdi).when(wmProxy).getDisplayInfo(any());
|
||||
doReturn(wm).when(wmProxy).getRealBounds(any(), any());
|
||||
doReturn(NavigationMode.NO_BUTTON).when(wmProxy).getNavigationMode(any());
|
||||
|
||||
ArrayMap<CachedDisplayInfo, List<WindowBounds>> perDisplayBoundsCache =
|
||||
new ArrayMap<>();
|
||||
perDisplayBoundsCache.put(cdi.normalize(wmProxy), allBounds);
|
||||
|
||||
Configuration configuration = new Configuration();
|
||||
configuration.densityDpi = mDensityDpi;
|
||||
Context configurationContext = app.createConfigurationContext(configuration);
|
||||
|
||||
DisplayController.Info info = new Info(
|
||||
configurationContext, false, wmProxy, perDisplayBoundsCache, mDensityDpi);
|
||||
when(mockController.getInfo()).thenReturn(info);
|
||||
|
||||
mDeviceProfile = InvariantDeviceProfile.INSTANCE.get(app)
|
||||
.getBestMatch(mAppBounds.width(), mAppBounds.height(), rotation);
|
||||
mDeviceProfile.updateInsets(mLauncherInsets);
|
||||
|
||||
TaskViewSimulator tvs = new TaskViewSimulator(app,
|
||||
FallbackActivityInterface.INSTANCE, false, 0);
|
||||
tvs.setDp(mDeviceProfile);
|
||||
|
||||
int launcherRotation = info.rotation;
|
||||
if (mAppRotation < 0) {
|
||||
mAppRotation = launcherRotation;
|
||||
}
|
||||
|
||||
tvs.getOrientationState().update(launcherRotation, mAppRotation);
|
||||
if (mAppInsets == null) {
|
||||
mAppInsets = new Rect(mLauncherInsets);
|
||||
}
|
||||
tvs.setPreviewBounds(mAppBounds, mAppInsets);
|
||||
|
||||
tvs.fullScreenProgress.value = 1;
|
||||
tvs.recentsViewScale.value = tvs.getFullScreenScale();
|
||||
tvs.apply(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.filters.SmallTest
|
||||
import com.android.quickstep.RemoteAnimationTargets
|
||||
import com.android.quickstep.util.TransformParams.BuilderProxy.NO_OP
|
||||
import com.android.window.flags.Flags.FLAG_ENABLE_DESKTOP_RECENTS_TRANSITIONS_CORNERS_BUGFIX
|
||||
import com.android.window.flags2.Flags.FLAG_ENABLE_DESKTOP_RECENTS_TRANSITIONS_CORNERS_BUGFIX
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
|
||||
Reference in new issue
Block a user