From 3fde467b410fcadab11dec029e0fb242802e4b2a Mon Sep 17 00:00:00 2001 From: Alex Chau Date: Wed, 3 Jul 2024 17:28:59 +0100 Subject: [PATCH] Make DeskopTaskView use latest TTV - Made TaskThumbnailViewDeprecated nullable in TaskContainer, with non-null getter that requires feature flag to be on/off - Removed TaskThumbnailViewDeprecated.setTaskOverlay, as it'll now be null with feature flag on - Removed TaskThumbnailViewDeprecated from DesktopTaskView xml - Simplifed DesktopTaskView binding logic, to always get thumbnailViews from viewPool, removeView and recycle all thumbnailViews in onRecycle - Didn't implement view pooling of TaskThumbnailView due to difficulty with TaskContainer not being recycled togetehr with TaskThumbnailView Bug: 338360089 Test: TaskThumbnailViewModelTest Test: manual testing for DesktopTaskView for both enable_refactor_task_thumbnail on and off Flag: com.android.launcher3.enable_refactor_task_thumbnail Flag: com.android.window.flags.enable_desktop_windowing_mode Change-Id: I38a6dfc6bc561689578d1660794f91d30bad4a68 --- quickstep/res/layout/task_desktop.xml | 9 -- .../task/thumbnail/TaskThumbnailView.kt | 18 ++- .../task/thumbnail/TaskThumbnailViewModel.kt | 9 +- .../quickstep/task/viewmodel/TaskViewData.kt | 7 +- .../android/quickstep/util/DesktopTask.java | 4 +- .../com/android/quickstep/util/GroupTask.java | 9 +- .../quickstep/views/DesktopTaskView.kt | 137 ++++++++---------- .../quickstep/views/GroupedTaskView.kt | 2 +- .../android/quickstep/views/RecentsView.java | 16 +- .../android/quickstep/views/TaskContainer.kt | 35 +++-- .../views/TaskThumbnailViewDeprecated.java | 11 -- .../com/android/quickstep/views/TaskView.kt | 36 ++--- .../android/quickstep/views/TaskViewType.kt | 24 +++ .../thumbnail/TaskThumbnailViewModelTest.kt | 25 +++- .../android/quickstep/util/GroupTaskTest.kt | 14 +- .../quickstep/DesktopSystemShortcutTest.kt | 1 - .../quickstep/RecentTasksListTest.java | 4 +- 17 files changed, 195 insertions(+), 166 deletions(-) create mode 100644 quickstep/src/com/android/quickstep/views/TaskViewType.kt diff --git a/quickstep/res/layout/task_desktop.xml b/quickstep/res/layout/task_desktop.xml index 89e9b3d9fd..453057c98a 100644 --- a/quickstep/res/layout/task_desktop.xml +++ b/quickstep/res/layout/task_desktop.xml @@ -36,15 +36,6 @@ android:layout_width="match_parent" android:layout_height="match_parent" /> - - - inheritedScale = viewModelInheritedScale @@ -117,6 +118,11 @@ class TaskThumbnailView : View { } } + override fun onRecycle() { + // Do nothing + uiState = Uninitialized + } + override fun onDraw(canvas: Canvas) { when (val uiStateVal = uiState) { is Uninitialized -> drawBackgroundOnly(canvas, Color.BLACK) @@ -138,7 +144,7 @@ class TaskThumbnailView : View { override fun onConfigurationChanged(newConfig: Configuration?) { super.onConfigurationChanged(newConfig) - cornerRadius = TaskCornerRadius.get(context) + overviewCornerRadius = TaskCornerRadius.get(context) fullscreenCornerRadius = QuickStepContract.getWindowCornerRadius(context) invalidateOutline() } @@ -159,8 +165,8 @@ class TaskThumbnailView : View { private fun getCurrentCornerRadius() = Utilities.mapRange( - viewModel.recentsFullscreenProgress.value, - cornerRadius, + viewModel.cornerRadiusProgress.value, + overviewCornerRadius, fullscreenCornerRadius ) / inheritedScale diff --git a/quickstep/src/com/android/quickstep/task/thumbnail/TaskThumbnailViewModel.kt b/quickstep/src/com/android/quickstep/task/thumbnail/TaskThumbnailViewModel.kt index fe211741b8..d8729a6a41 100644 --- a/quickstep/src/com/android/quickstep/task/thumbnail/TaskThumbnailViewModel.kt +++ b/quickstep/src/com/android/quickstep/task/thumbnail/TaskThumbnailViewModel.kt @@ -31,6 +31,7 @@ import com.android.systemui.shared.recents.model.Task import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.flatMapLatest @@ -47,7 +48,13 @@ class TaskThumbnailViewModel( private val task = MutableStateFlow>(flowOf(null)) private var boundTaskIsRunning = false - val recentsFullscreenProgress = recentsViewData.fullscreenProgress + /** + * Progress for changes in corner radius. progress: 0 = overview corner radius; 1 = fullscreen + * corner radius. + */ + val cornerRadiusProgress = + if (taskViewData.isOutlineFormedByThumbnailView) recentsViewData.fullscreenProgress + else MutableStateFlow(1f).asStateFlow() val inheritedScale = combine(recentsViewData.scale, taskViewData.scale) { recentsScale, taskScale -> recentsScale * taskScale diff --git a/quickstep/src/com/android/quickstep/task/viewmodel/TaskViewData.kt b/quickstep/src/com/android/quickstep/task/viewmodel/TaskViewData.kt index a8b5112860..7a9ecf2426 100644 --- a/quickstep/src/com/android/quickstep/task/viewmodel/TaskViewData.kt +++ b/quickstep/src/com/android/quickstep/task/viewmodel/TaskViewData.kt @@ -16,9 +16,14 @@ package com.android.quickstep.task.viewmodel +import com.android.quickstep.views.TaskViewType import kotlinx.coroutines.flow.MutableStateFlow -class TaskViewData { +class TaskViewData(taskViewType: TaskViewType) { // This is typically a View concern but it is used to invalidate rendering in other Views val scale = MutableStateFlow(1f) + + // TODO(b/331753115): This property should not be in TaskViewData once TaskView is MVVM. + /** Whether outline of TaskView is formed by outline thumbnail view(s). */ + val isOutlineFormedByThumbnailView: Boolean = taskViewType != TaskViewType.DESKTOP } diff --git a/quickstep/src/com/android/quickstep/util/DesktopTask.java b/quickstep/src/com/android/quickstep/util/DesktopTask.java index 307b2faf85..a727aa2efb 100644 --- a/quickstep/src/com/android/quickstep/util/DesktopTask.java +++ b/quickstep/src/com/android/quickstep/util/DesktopTask.java @@ -18,7 +18,7 @@ package com.android.quickstep.util; import androidx.annotation.NonNull; -import com.android.quickstep.views.TaskView; +import com.android.quickstep.views.TaskViewType; import com.android.systemui.shared.recents.model.Task; import java.util.List; @@ -34,7 +34,7 @@ public class DesktopTask extends GroupTask { public final List tasks; public DesktopTask(@NonNull List tasks) { - super(tasks.get(0), null, null, TaskView.Type.DESKTOP); + super(tasks.get(0), null, null, TaskViewType.DESKTOP); this.tasks = tasks; } diff --git a/quickstep/src/com/android/quickstep/util/GroupTask.java b/quickstep/src/com/android/quickstep/util/GroupTask.java index e8b611c959..fba08a96b2 100644 --- a/quickstep/src/com/android/quickstep/util/GroupTask.java +++ b/quickstep/src/com/android/quickstep/util/GroupTask.java @@ -20,7 +20,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.android.launcher3.util.SplitConfigurationOptions.SplitBounds; -import com.android.quickstep.views.TaskView; +import com.android.quickstep.views.TaskViewType; import com.android.systemui.shared.recents.model.Task; import java.util.Arrays; @@ -39,19 +39,18 @@ public class GroupTask { public final Task task2; @Nullable public final SplitBounds mSplitBounds; - @TaskView.Type - public final int taskViewType; + public final TaskViewType taskViewType; public GroupTask(@NonNull Task task) { this(task, null, null); } public GroupTask(@NonNull Task t1, @Nullable Task t2, @Nullable SplitBounds splitBounds) { - this(t1, t2, splitBounds, t2 != null ? TaskView.Type.GROUPED : TaskView.Type.SINGLE); + this(t1, t2, splitBounds, t2 != null ? TaskViewType.GROUPED : TaskViewType.SINGLE); } protected GroupTask(@NonNull Task t1, @Nullable Task t2, @Nullable SplitBounds splitBounds, - @TaskView.Type int taskViewType) { + TaskViewType taskViewType) { task1 = t1; task2 = t2; mSplitBounds = splitBounds; diff --git a/quickstep/src/com/android/quickstep/views/DesktopTaskView.kt b/quickstep/src/com/android/quickstep/views/DesktopTaskView.kt index 55bbd50d41..4333c8b905 100644 --- a/quickstep/src/com/android/quickstep/views/DesktopTaskView.kt +++ b/quickstep/src/com/android/quickstep/views/DesktopTaskView.kt @@ -27,6 +27,7 @@ import android.util.Log import android.view.View import android.view.ViewGroup import androidx.core.view.updateLayoutParams +import com.android.launcher3.Flags.enableRefactorTaskThumbnail import com.android.launcher3.R import com.android.launcher3.util.RunnableList import com.android.launcher3.util.SplitConfigurationOptions @@ -35,12 +36,13 @@ import com.android.launcher3.util.ViewPool import com.android.launcher3.util.rects.set import com.android.quickstep.BaseContainerInterface import com.android.quickstep.TaskOverlayFactory +import com.android.quickstep.task.thumbnail.TaskThumbnailView import com.android.quickstep.util.RecentsOrientedState import com.android.systemui.shared.recents.model.Task /** TaskView that contains all tasks that are part of the desktop. */ class DesktopTaskView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : - TaskView(context, attrs) { + TaskView(context, attrs, type = TaskViewType.DESKTOP) { private val snapshotDrawParams = object : FullscreenDrawParams(context) { @@ -48,7 +50,7 @@ class DesktopTaskView @JvmOverloads constructor(context: Context, attrs: Attribu override fun computeTaskCornerRadius(context: Context) = computeWindowCornerRadius(context) } - private val taskThumbnailViewPool = + private val taskThumbnailViewDeprecatedPool = ViewPool( context, this, @@ -89,6 +91,66 @@ class DesktopTaskView @JvmOverloads constructor(context: Context, attrs: Attribu childCountAtInflation = childCount } + /** Updates this desktop task to the gives task list defined in `tasks` */ + fun bind( + tasks: List, + orientedState: RecentsOrientedState, + taskOverlayFactory: TaskOverlayFactory + ) { + if (DEBUG) { + val sb = StringBuilder() + sb.append("bind tasks=").append(tasks.size).append("\n") + tasks.forEach { sb.append(" key=${it.key}\n") } + Log.d(TAG, sb.toString()) + } + cancelPendingLoadTasks() + taskContainers = + tasks.map { task -> + val snapshotView = + if (enableRefactorTaskThumbnail()) { + TaskThumbnailView(context) + } else { + taskThumbnailViewDeprecatedPool.view + } + .also { snapshotView -> + addView( + snapshotView, + // Add snapshotView to the front after initial views e.g. icon and + // background. + childCountAtInflation, + LayoutParams( + ViewGroup.LayoutParams.WRAP_CONTENT, + ViewGroup.LayoutParams.WRAP_CONTENT + ) + ) + } + TaskContainer( + this, + task, + snapshotView, + iconView, + TransformingTouchDelegate(iconView.asView()), + SplitConfigurationOptions.STAGE_POSITION_UNDEFINED, + digitalWellBeingToast = null, + showWindowsView = null, + taskOverlayFactory + ) + } + taskContainers.forEach { it.bind() } + setOrientationState(orientedState) + } + + override fun onRecycle() { + super.onRecycle() + visibility = VISIBLE + taskContainers.forEach { + if (!enableRefactorTaskThumbnail()) { + removeView(it.thumbnailViewDeprecated) + taskThumbnailViewDeprecatedPool.recycle(it.thumbnailViewDeprecated) + } + } + } + override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) { super.onMeasure(widthMeasureSpec, heightMeasureSpec) val containerWidth = MeasureSpec.getSize(widthMeasureSpec) @@ -151,77 +213,6 @@ class DesktopTaskView @JvmOverloads constructor(context: Context, attrs: Attribu } } - override fun onRecycle() { - super.onRecycle() - visibility = VISIBLE - } - - /** Updates this desktop task to the gives task list defined in `tasks` */ - fun bind( - tasks: List, - orientedState: RecentsOrientedState, - taskOverlayFactory: TaskOverlayFactory - ) { - if (DEBUG) { - val sb = StringBuilder() - sb.append("bind tasks=").append(tasks.size).append("\n") - tasks.forEach { sb.append(" key=${it.key}\n") } - Log.d(TAG, sb.toString()) - } - cancelPendingLoadTasks() - - if (!isTaskContainersInitialized()) { - taskContainers = arrayListOf() - } - val taskContainers = taskContainers as ArrayList - taskContainers.ensureCapacity(tasks.size) - tasks.forEachIndexed { index, task -> - val thumbnailViewDeprecated: TaskThumbnailViewDeprecated - if (index >= taskContainers.size) { - thumbnailViewDeprecated = taskThumbnailViewPool.view - // Add thumbnailView from to position after the initial child views. - addView( - thumbnailViewDeprecated, - childCountAtInflation, - LayoutParams( - ViewGroup.LayoutParams.WRAP_CONTENT, - ViewGroup.LayoutParams.WRAP_CONTENT - ) - ) - } else { - thumbnailViewDeprecated = taskContainers[index].thumbnailViewDeprecated - } - val taskContainer = - TaskContainer( - this, - task, - // TODO(b/338360089): Support new TTV for DesktopTaskView - thumbnailView = null, - thumbnailViewDeprecated, - iconView, - TransformingTouchDelegate(iconView.asView()), - SplitConfigurationOptions.STAGE_POSITION_UNDEFINED, - digitalWellBeingToast = null, - showWindowsView = null, - taskOverlayFactory - ) - if (index >= taskContainers.size) { - taskContainers.add(taskContainer) - } else { - taskContainers[index] = taskContainer - } - taskContainer.bind() - } - repeat(taskContainers.size - tasks.size) { - with(taskContainers.removeLast()) { - removeView(thumbnailViewDeprecated) - taskThumbnailViewPool.recycle(thumbnailViewDeprecated) - } - } - - setOrientationState(orientedState) - } - override fun needsUpdate(dataChange: Int, flag: Int) = if (flag == FLAG_UPDATE_THUMBNAIL) super.needsUpdate(dataChange, flag) else false diff --git a/quickstep/src/com/android/quickstep/views/GroupedTaskView.kt b/quickstep/src/com/android/quickstep/views/GroupedTaskView.kt index b070244304..6523ba7778 100644 --- a/quickstep/src/com/android/quickstep/views/GroupedTaskView.kt +++ b/quickstep/src/com/android/quickstep/views/GroupedTaskView.kt @@ -49,7 +49,7 @@ import com.android.wm.shell.common.split.SplitScreenConstants.PersistentSnapPosi * (Icon loading sold separately, fees may apply. Shipping & Handling for Overlays not included). */ class GroupedTaskView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : - TaskView(context, attrs) { + TaskView(context, attrs, type = TaskViewType.GROUPED) { // TODO(b/336612373): Support new TTV for GroupedTaskView var splitBoundsConfig: SplitConfigurationOptions.SplitBounds? = null private set diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index ee1b3e7e87..f3e0ede80f 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -1824,7 +1824,7 @@ public abstract class RecentsView = taskOverlayFactory.createOverlay(this) val taskContainerData = TaskContainerData() - val snapshotView: View - get() = thumbnailView ?: thumbnailViewDeprecated + init { + if (enableRefactorTaskThumbnail()) { + require(snapshotView is TaskThumbnailView) + } else { + require(snapshotView is TaskThumbnailViewDeprecated) + } + } + + val thumbnailView: TaskThumbnailView + get() { + require(enableRefactorTaskThumbnail()) + return snapshotView as TaskThumbnailView + } + + val thumbnailViewDeprecated: TaskThumbnailViewDeprecated + get() { + require(!enableRefactorTaskThumbnail()) + return snapshotView as TaskThumbnailViewDeprecated + } // TODO(b/349120849): Extract ThumbnailData from TaskContainerData/TaskThumbnailViewModel val thumbnail: Bitmap? - get() = thumbnailViewDeprecated.thumbnail + get() = if (enableRefactorTaskThumbnail()) null else thumbnailViewDeprecated.thumbnail // TODO(b/334826842): Support shouldShowSplashView for new TTV. val shouldShowSplashView: Boolean @@ -100,13 +116,14 @@ class TaskContainer( fun destroy() { digitalWellBeingToast?.destroy() - thumbnailView?.let { taskView.removeView(it) } + if (enableRefactorTaskThumbnail()) { + taskView.removeView(thumbnailView) + } overlay.destroy() } fun bind() { - if (enableRefactorTaskThumbnail() && thumbnailView != null) { - thumbnailViewDeprecated.setTaskOverlay(overlay) + if (enableRefactorTaskThumbnail()) { bindThumbnailView() overlay.init() } else { @@ -119,7 +136,7 @@ class TaskContainer( fun bindThumbnailView() { // TODO(b/343364498): Existing view has shouldShowScreenshot as an override as well but // this should be decided inside TaskThumbnailViewModel. - thumbnailView?.viewModel?.bind(TaskThumbnail(task.key.id, taskView.isRunningTask)) + thumbnailView.viewModel.bind(TaskThumbnail(task.key.id, taskView.isRunningTask)) } fun setOverlayEnabled(enabled: Boolean) { diff --git a/quickstep/src/com/android/quickstep/views/TaskThumbnailViewDeprecated.java b/quickstep/src/com/android/quickstep/views/TaskThumbnailViewDeprecated.java index 5b7e6c7ff2..56ca043a79 100644 --- a/quickstep/src/com/android/quickstep/views/TaskThumbnailViewDeprecated.java +++ b/quickstep/src/com/android/quickstep/views/TaskThumbnailViewDeprecated.java @@ -164,17 +164,6 @@ public class TaskThumbnailViewDeprecated extends View implements ViewPool.Reusab updateSplashView(mTask.icon); } - /** - * Sets TaskOverlay without binding a task. - * - * @deprecated Should only be used when using new - * {@link com.android.quickstep.task.thumbnail.TaskThumbnailView}. - */ - @Deprecated - public void setTaskOverlay(TaskOverlay overlay) { - mOverlay = overlay; - } - /** * Updates the thumbnail. * diff --git a/quickstep/src/com/android/quickstep/views/TaskView.kt b/quickstep/src/com/android/quickstep/views/TaskView.kt index 9977d30fe9..2e07e36a8f 100644 --- a/quickstep/src/com/android/quickstep/views/TaskView.kt +++ b/quickstep/src/com/android/quickstep/views/TaskView.kt @@ -102,7 +102,8 @@ constructor( defStyleAttr: Int = 0, defStyleRes: Int = 0, focusBorderAnimator: BorderAnimator? = null, - hoverBorderAnimator: BorderAnimator? = null + hoverBorderAnimator: BorderAnimator? = null, + type: TaskViewType = TaskViewType.SINGLE ) : FrameLayout(context, attrs), ViewPool.Reusable { /** * Used in conjunction with [onTaskListVisibilityChanged], providing more granularity on which @@ -112,18 +113,7 @@ constructor( @IntDef(FLAG_UPDATE_ALL, FLAG_UPDATE_ICON, FLAG_UPDATE_THUMBNAIL, FLAG_UPDATE_CORNER_RADIUS) annotation class TaskDataChanges - /** Type of task view */ - @Retention(AnnotationRetention.SOURCE) - @IntDef(Type.SINGLE, Type.GROUPED, Type.DESKTOP) - annotation class Type { - companion object { - const val SINGLE = 1 - const val GROUPED = 2 - const val DESKTOP = 3 - } - } - - val taskViewData = TaskViewData() + val taskViewData = TaskViewData(type) val taskIds: IntArray /** Returns a copy of integer array containing taskIds of all tasks in the TaskView. */ get() = taskContainers.map { it.task.key.id }.toIntArray() @@ -671,24 +661,22 @@ constructor( taskOverlayFactory: TaskOverlayFactory ): TaskContainer { val thumbnailViewDeprecated: TaskThumbnailViewDeprecated = findViewById(thumbnailViewId)!! - val thumbnailView: TaskThumbnailView? - if (enableRefactorTaskThumbnail()) { - val indexOfSnapshotView = indexOfChild(thumbnailViewDeprecated) - thumbnailView = + val snapshotView = + if (enableRefactorTaskThumbnail()) { + thumbnailViewDeprecated.visibility = GONE + val indexOfSnapshotView = indexOfChild(thumbnailViewDeprecated) TaskThumbnailView(context).apply { layoutParams = thumbnailViewDeprecated.layoutParams addView(this, indexOfSnapshotView) } - thumbnailViewDeprecated.visibility = GONE - } else { - thumbnailView = null - } + } else { + thumbnailViewDeprecated + } val iconView = getOrInflateIconView(iconViewId) return TaskContainer( this, task, - thumbnailView, - thumbnailViewDeprecated, + snapshotView, iconView, TransformingTouchDelegate(iconView.asView()), stagePosition, @@ -710,8 +698,6 @@ constructor( .inflate() as TaskViewIcon } - protected fun isTaskContainersInitialized() = this::taskContainers.isInitialized - fun containsMultipleTasks() = taskContainers.size > 1 /** diff --git a/quickstep/src/com/android/quickstep/views/TaskViewType.kt b/quickstep/src/com/android/quickstep/views/TaskViewType.kt new file mode 100644 index 0000000000..b2a32a96c8 --- /dev/null +++ b/quickstep/src/com/android/quickstep/views/TaskViewType.kt @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2024 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.quickstep.views + +/** Type of the [TaskView] */ +enum class TaskViewType { + SINGLE, + GROUPED, + DESKTOP +} diff --git a/quickstep/tests/multivalentTests/src/com/android/quickstep/task/thumbnail/TaskThumbnailViewModelTest.kt b/quickstep/tests/multivalentTests/src/com/android/quickstep/task/thumbnail/TaskThumbnailViewModelTest.kt index a394b6530b..b78f871a21 100644 --- a/quickstep/tests/multivalentTests/src/com/android/quickstep/task/thumbnail/TaskThumbnailViewModelTest.kt +++ b/quickstep/tests/multivalentTests/src/com/android/quickstep/task/thumbnail/TaskThumbnailViewModelTest.kt @@ -30,6 +30,7 @@ import com.android.quickstep.task.thumbnail.TaskThumbnailUiState.Snapshot import com.android.quickstep.task.thumbnail.TaskThumbnailUiState.Uninitialized import com.android.quickstep.task.viewmodel.TaskContainerData import com.android.quickstep.task.viewmodel.TaskViewData +import com.android.quickstep.views.TaskViewType import com.android.systemui.shared.recents.model.Task import com.android.systemui.shared.recents.model.ThumbnailData import com.google.common.truth.Truth.assertThat @@ -42,12 +43,14 @@ import org.mockito.kotlin.whenever @RunWith(AndroidJUnit4::class) class TaskThumbnailViewModelTest { + private var taskViewType = TaskViewType.SINGLE private val recentsViewData = RecentsViewData() - private val taskViewData = TaskViewData() + private val taskViewData by lazy { TaskViewData(taskViewType) } private val taskContainerData = TaskContainerData() private val tasksRepository = FakeTasksRepository() - private val systemUnderTest = + private val systemUnderTest by lazy { TaskThumbnailViewModel(recentsViewData, taskViewData, taskContainerData, tasksRepository) + } private val tasks = (0..5).map(::createTaskWithId) @@ -66,14 +69,26 @@ class TaskThumbnailViewModelTest { } @Test - fun setRecentsFullscreenProgress_thenProgressIsPassedThrough() = runTest { + fun setRecentsFullscreenProgress_thenCornerRadiusProgressIsPassedThrough() = runTest { recentsViewData.fullscreenProgress.value = 0.5f - assertThat(systemUnderTest.recentsFullscreenProgress.first()).isEqualTo(0.5f) + assertThat(systemUnderTest.cornerRadiusProgress.first()).isEqualTo(0.5f) recentsViewData.fullscreenProgress.value = 0.6f - assertThat(systemUnderTest.recentsFullscreenProgress.first()).isEqualTo(0.6f) + assertThat(systemUnderTest.cornerRadiusProgress.first()).isEqualTo(0.6f) + } + + @Test + fun setRecentsFullscreenProgress_thenCornerRadiusProgressIsConstantForDesktop() = runTest { + taskViewType = TaskViewType.DESKTOP + recentsViewData.fullscreenProgress.value = 0.5f + + assertThat(systemUnderTest.cornerRadiusProgress.first()).isEqualTo(1f) + + recentsViewData.fullscreenProgress.value = 0.6f + + assertThat(systemUnderTest.cornerRadiusProgress.first()).isEqualTo(1f) } @Test diff --git a/quickstep/tests/multivalentTests/src/com/android/quickstep/util/GroupTaskTest.kt b/quickstep/tests/multivalentTests/src/com/android/quickstep/util/GroupTaskTest.kt index a6d3887538..f11cd0b7b5 100644 --- a/quickstep/tests/multivalentTests/src/com/android/quickstep/util/GroupTaskTest.kt +++ b/quickstep/tests/multivalentTests/src/com/android/quickstep/util/GroupTaskTest.kt @@ -21,7 +21,7 @@ import android.content.Intent import android.graphics.Rect import com.android.launcher3.util.LauncherMultivalentJUnit import com.android.launcher3.util.SplitConfigurationOptions -import com.android.quickstep.views.TaskView +import com.android.quickstep.views.TaskViewType import com.android.systemui.shared.recents.model.Task import com.android.wm.shell.common.split.SplitScreenConstants import com.google.common.truth.Truth.assertThat @@ -68,8 +68,8 @@ class GroupTaskTest { 2, SplitScreenConstants.SNAP_TO_50_50 ) - val task1 = GroupTask(createTask(1), createTask(2), splitBounds, TaskView.Type.GROUPED) - val task2 = GroupTask(createTask(1), createTask(2), splitBounds, TaskView.Type.GROUPED) + val task1 = GroupTask(createTask(1), createTask(2), splitBounds, TaskViewType.GROUPED) + val task2 = GroupTask(createTask(1), createTask(2), splitBounds, TaskViewType.GROUPED) assertThat(task1).isEqualTo(task2) } @@ -91,15 +91,15 @@ class GroupTaskTest { 2, SplitScreenConstants.SNAP_TO_30_70 ) - val task1 = GroupTask(createTask(1), createTask(2), splitBounds1, TaskView.Type.GROUPED) - val task2 = GroupTask(createTask(1), createTask(2), splitBounds2, TaskView.Type.GROUPED) + val task1 = GroupTask(createTask(1), createTask(2), splitBounds1, TaskViewType.GROUPED) + val task2 = GroupTask(createTask(1), createTask(2), splitBounds2, TaskViewType.GROUPED) assertThat(task1).isNotEqualTo(task2) } @Test fun testGroupTask_differentType_isNotEqual() { - val task1 = GroupTask(createTask(1), null, null, TaskView.Type.SINGLE) - val task2 = GroupTask(createTask(1), null, null, TaskView.Type.DESKTOP) + val task1 = GroupTask(createTask(1), null, null, TaskViewType.SINGLE) + val task2 = GroupTask(createTask(1), null, null, TaskViewType.DESKTOP) assertThat(task1).isNotEqualTo(task2) } diff --git a/quickstep/tests/src/com/android/quickstep/DesktopSystemShortcutTest.kt b/quickstep/tests/src/com/android/quickstep/DesktopSystemShortcutTest.kt index f160ce2112..63ffd2d5bc 100644 --- a/quickstep/tests/src/com/android/quickstep/DesktopSystemShortcutTest.kt +++ b/quickstep/tests/src/com/android/quickstep/DesktopSystemShortcutTest.kt @@ -191,7 +191,6 @@ class DesktopSystemShortcutTest { return TaskContainer( taskView, task, - thumbnailView = null, thumbnailViewDeprecated, iconView, transformingTouchDelegate, diff --git a/quickstep/tests/src/com/android/quickstep/RecentTasksListTest.java b/quickstep/tests/src/com/android/quickstep/RecentTasksListTest.java index ce16b70a1b..5d00255882 100644 --- a/quickstep/tests/src/com/android/quickstep/RecentTasksListTest.java +++ b/quickstep/tests/src/com/android/quickstep/RecentTasksListTest.java @@ -32,7 +32,7 @@ import androidx.test.filters.SmallTest; import com.android.launcher3.util.LooperExecutor; import com.android.quickstep.util.GroupTask; -import com.android.quickstep.views.TaskView; +import com.android.quickstep.views.TaskViewType; import com.android.systemui.shared.recents.model.Task; import com.android.wm.shell.util.GroupedRecentTaskInfo; @@ -125,7 +125,7 @@ public class RecentTasksListTest { Integer.MAX_VALUE /* numTasks */, -1 /* requestId */, false /* loadKeysOnly */); assertEquals(1, taskList.size()); - assertEquals(TaskView.Type.DESKTOP, taskList.get(0).taskViewType); + assertEquals(TaskViewType.DESKTOP, taskList.get(0).taskViewType); List actualFreeformTasks = taskList.get(0).getTasks(); assertEquals(3, actualFreeformTasks.size()); assertEquals(1, actualFreeformTasks.get(0).key.id);