Merge changes I31d9a51e,I1bc14be7 into main
* changes: Prevent requestLayout() when updating drawables that don't change size Fix splash icon size to 52dp
This commit is contained in:
commit
37752f5e19
19 files changed
+109
-245
No files matched your search
-2
@@ -20,8 +20,6 @@ class FakeRecentsDeviceProfileRepository : RecentsDeviceProfileRepository {
|
||||
private var recentsDeviceProfile =
|
||||
RecentsDeviceProfile(
|
||||
isLargeScreen = false,
|
||||
widthPx = 1080,
|
||||
heightPx = 1920,
|
||||
)
|
||||
|
||||
override fun getRecentsDeviceProfile() = recentsDeviceProfile
|
||||
|
||||
+1
-1
@@ -39,6 +39,6 @@ class RecentsDeviceProfileRepositoryImplTest : FakeInvariantDeviceProfileTest()
|
||||
whenever(recentsViewContainer.deviceProfile).thenReturn(tabletDeviceProfile)
|
||||
|
||||
assertThat(systemUnderTest.getRecentsDeviceProfile())
|
||||
.isEqualTo(RecentsDeviceProfile(isLargeScreen = true, widthPx = 1600, heightPx = 2560))
|
||||
.isEqualTo(RecentsDeviceProfile(isLargeScreen = true))
|
||||
}
|
||||
}
|
||||
-84
@@ -1,84 +0,0 @@
|
||||
/*
|
||||
* 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.task.thumbnail
|
||||
|
||||
import android.graphics.Point
|
||||
import android.graphics.drawable.Drawable
|
||||
import com.android.quickstep.recents.data.FakeRecentsDeviceProfileRepository
|
||||
import com.android.quickstep.task.viewmodel.TaskViewData
|
||||
import com.android.quickstep.views.TaskViewType
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import org.junit.Test
|
||||
import org.mockito.kotlin.mock
|
||||
import org.mockito.kotlin.whenever
|
||||
|
||||
class GetSplashSizeUseCaseTest {
|
||||
private val taskThumbnailViewData = TaskThumbnailViewData()
|
||||
private val taskViewData = TaskViewData(TaskViewType.SINGLE)
|
||||
private val recentsDeviceProfileRepository = FakeRecentsDeviceProfileRepository()
|
||||
private val systemUnderTest =
|
||||
GetSplashSizeUseCase(taskThumbnailViewData, taskViewData, recentsDeviceProfileRepository)
|
||||
|
||||
@Test
|
||||
fun execute_whenNoScaleRequired_returnsIntrinsicSize() {
|
||||
taskThumbnailViewData.width.value =
|
||||
recentsDeviceProfileRepository.getRecentsDeviceProfile().widthPx
|
||||
taskThumbnailViewData.height.value =
|
||||
recentsDeviceProfileRepository.getRecentsDeviceProfile().heightPx
|
||||
|
||||
assertThat(systemUnderTest.execute(createIcon(100, 100))).isEqualTo(Point(100, 100))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun execute_whenThumbnailViewIsSmallerThanScreen_returnsScaledSize() {
|
||||
taskThumbnailViewData.width.value =
|
||||
recentsDeviceProfileRepository.getRecentsDeviceProfile().widthPx / 2
|
||||
taskThumbnailViewData.height.value =
|
||||
recentsDeviceProfileRepository.getRecentsDeviceProfile().heightPx / 2
|
||||
|
||||
assertThat(systemUnderTest.execute(createIcon(100, 100))).isEqualTo(Point(50, 50))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun execute_whenThumbnailViewIsSmallerThanScreen_withNonGridScale_returnsScaledSize() {
|
||||
taskThumbnailViewData.width.value =
|
||||
recentsDeviceProfileRepository.getRecentsDeviceProfile().widthPx / 2
|
||||
taskThumbnailViewData.height.value =
|
||||
recentsDeviceProfileRepository.getRecentsDeviceProfile().heightPx / 2
|
||||
taskViewData.nonGridScale.value = 2f
|
||||
|
||||
assertThat(systemUnderTest.execute(createIcon(100, 100))).isEqualTo(Point(25, 25))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun execute_whenThumbnailViewIsSmallerThanScreen_withThumbnailViewScale_returnsScaledSize() {
|
||||
taskThumbnailViewData.width.value =
|
||||
recentsDeviceProfileRepository.getRecentsDeviceProfile().widthPx / 2
|
||||
taskThumbnailViewData.height.value =
|
||||
recentsDeviceProfileRepository.getRecentsDeviceProfile().heightPx / 2
|
||||
taskThumbnailViewData.scaleX.value = 2f
|
||||
taskThumbnailViewData.scaleY.value = 2f
|
||||
|
||||
assertThat(systemUnderTest.execute(createIcon(100, 100))).isEqualTo(Point(25, 25))
|
||||
}
|
||||
|
||||
private fun createIcon(width: Int, height: Int): Drawable =
|
||||
mock<Drawable>().apply {
|
||||
whenever(intrinsicWidth).thenReturn(width)
|
||||
whenever(intrinsicHeight).thenReturn(height)
|
||||
}
|
||||
}
|
||||
+3
-31
@@ -21,7 +21,6 @@ import android.content.Intent
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.Color
|
||||
import android.graphics.Matrix
|
||||
import android.graphics.Point
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.view.Surface
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
@@ -35,7 +34,6 @@ import com.android.quickstep.task.thumbnail.TaskThumbnailUiState.BackgroundOnly
|
||||
import com.android.quickstep.task.thumbnail.TaskThumbnailUiState.LiveTile
|
||||
import com.android.quickstep.task.thumbnail.TaskThumbnailUiState.Snapshot
|
||||
import com.android.quickstep.task.thumbnail.TaskThumbnailUiState.SnapshotSplash
|
||||
import com.android.quickstep.task.thumbnail.TaskThumbnailUiState.Splash
|
||||
import com.android.quickstep.task.thumbnail.TaskThumbnailUiState.Uninitialized
|
||||
import com.android.quickstep.task.viewmodel.TaskContainerData
|
||||
import com.android.quickstep.task.viewmodel.TaskThumbnailViewModel
|
||||
@@ -46,10 +44,8 @@ import com.android.systemui.shared.recents.model.ThumbnailData
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.kotlin.any
|
||||
import org.mockito.kotlin.mock
|
||||
import org.mockito.kotlin.whenever
|
||||
|
||||
@@ -63,7 +59,6 @@ class TaskThumbnailViewModelTest {
|
||||
private val tasksRepository = FakeTasksRepository()
|
||||
private val mGetThumbnailPositionUseCase = mock<GetThumbnailPositionUseCase>()
|
||||
private val splashAlphaUseCase: SplashAlphaUseCase = mock()
|
||||
private val getSplashSizeUseCase: GetSplashSizeUseCase = mock()
|
||||
private val systemUnderTest by lazy {
|
||||
TaskThumbnailViewModel(
|
||||
recentsViewData,
|
||||
@@ -72,17 +67,11 @@ class TaskThumbnailViewModelTest {
|
||||
tasksRepository,
|
||||
mGetThumbnailPositionUseCase,
|
||||
splashAlphaUseCase,
|
||||
getSplashSizeUseCase,
|
||||
)
|
||||
}
|
||||
|
||||
private val tasks = (0..5).map(::createTaskWithId)
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
whenever(getSplashSizeUseCase.execute(any())).thenReturn(Point())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun initialStateIsUninitialized() = runTest {
|
||||
assertThat(systemUnderTest.uiState.first()).isEqualTo(Uninitialized)
|
||||
@@ -120,7 +109,7 @@ class TaskThumbnailViewModelTest {
|
||||
bitmap = expectedThumbnailData.thumbnail!!,
|
||||
thumbnailRotation = Surface.ROTATION_0,
|
||||
),
|
||||
Splash(expectedIconData.icon, Point())
|
||||
expectedIconData.icon
|
||||
)
|
||||
)
|
||||
}
|
||||
@@ -215,7 +204,7 @@ class TaskThumbnailViewModelTest {
|
||||
bitmap = expectedThumbnailData.thumbnail!!,
|
||||
thumbnailRotation = Surface.ROTATION_270,
|
||||
),
|
||||
Splash(expectedIconData.icon, Point())
|
||||
expectedIconData.icon
|
||||
)
|
||||
)
|
||||
}
|
||||
@@ -241,28 +230,11 @@ class TaskThumbnailViewModelTest {
|
||||
bitmap = expectedThumbnailData.thumbnail!!,
|
||||
thumbnailRotation = Surface.ROTATION_0,
|
||||
),
|
||||
Splash(expectedIconData.icon, Point())
|
||||
expectedIconData.icon
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun bindStoppedTask_thenStateContainsSplashSizeFromUseCase() = runTest {
|
||||
val taskId = 2
|
||||
val expectedSplashSize = Point(100, 150)
|
||||
whenever(getSplashSizeUseCase.execute(any())).thenReturn(expectedSplashSize)
|
||||
val expectedThumbnailData = createThumbnailData(rotation = Surface.ROTATION_270)
|
||||
tasksRepository.seedThumbnailData(mapOf(taskId to expectedThumbnailData))
|
||||
val expectedIconData = createIconData("Task 2")
|
||||
tasksRepository.seedIconData(mapOf(taskId to expectedIconData))
|
||||
tasksRepository.seedTasks(tasks)
|
||||
tasksRepository.setVisibleTasks(listOf(taskId))
|
||||
|
||||
systemUnderTest.bind(taskId)
|
||||
val uiState = systemUnderTest.uiState.first() as SnapshotSplash
|
||||
assertThat(uiState.splash.size).isEqualTo(expectedSplashSize)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getSnapshotMatrix_MissingThumbnail() = runTest {
|
||||
val taskId = 2
|
||||
|
||||
Reference in new issue
Block a user