Merge "Fixes updateOverlayVisibility and updates SideFpsControllerTest for natural orientation shift" into tm-qpr-dev am: 5bdad5d547
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20950396 Change-Id: I7b0a6c24f3d82092e82f704b572d8ffd4f1e3606 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -111,7 +111,7 @@ constructor(
|
||||
context.resources.getInteger(android.R.integer.config_mediumAnimTime).toLong()
|
||||
|
||||
private val isReverseDefaultRotation =
|
||||
context.getResources().getBoolean(com.android.internal.R.bool.config_reverseDefaultRotation)
|
||||
context.resources.getBoolean(com.android.internal.R.bool.config_reverseDefaultRotation)
|
||||
|
||||
private var overlayHideAnimator: ViewPropertyAnimator? = null
|
||||
|
||||
@@ -268,10 +268,12 @@ constructor(
|
||||
val isDefaultOrientation =
|
||||
if (isReverseDefaultRotation) !isNaturalOrientation else isNaturalOrientation
|
||||
val size = windowManager.maximumWindowMetrics.bounds
|
||||
|
||||
val displayWidth = if (isDefaultOrientation) size.width() else size.height()
|
||||
val displayHeight = if (isDefaultOrientation) size.height() else size.width()
|
||||
val boundsWidth = if (isDefaultOrientation) bounds.width() else bounds.height()
|
||||
val boundsHeight = if (isDefaultOrientation) bounds.height() else bounds.width()
|
||||
|
||||
val sensorBounds =
|
||||
if (overlayOffsets.isYAligned()) {
|
||||
Rect(
|
||||
@@ -297,6 +299,7 @@ constructor(
|
||||
|
||||
overlayViewParams.x = sensorBounds.left
|
||||
overlayViewParams.y = sensorBounds.top
|
||||
|
||||
windowManager.updateViewLayout(overlayView, overlayViewParams)
|
||||
}
|
||||
|
||||
@@ -306,7 +309,12 @@ constructor(
|
||||
}
|
||||
// hide after a few seconds if the sensor is oriented down and there are
|
||||
// large overlapping system bars
|
||||
val rotation = context.display?.rotation
|
||||
var rotation = context.display?.rotation
|
||||
|
||||
if (rotation != null) {
|
||||
rotation = getRotationFromDefault(rotation)
|
||||
}
|
||||
|
||||
if (
|
||||
windowManager.currentWindowMetrics.windowInsets.hasBigNavigationBar() &&
|
||||
((rotation == Surface.ROTATION_270 && overlayOffsets.isYAligned()) ||
|
||||
|
||||
@@ -53,6 +53,7 @@ import androidx.test.filters.SmallTest
|
||||
import com.airbnb.lottie.LottieAnimationView
|
||||
import com.android.systemui.R
|
||||
import com.android.systemui.SysuiTestCase
|
||||
import com.android.systemui.SysuiTestableContext
|
||||
import com.android.systemui.dump.DumpManager
|
||||
import com.android.systemui.recents.OverviewProxyService
|
||||
import com.android.systemui.util.concurrency.FakeExecutor
|
||||
@@ -106,8 +107,7 @@ class SideFpsControllerTest : SysuiTestCase() {
|
||||
|
||||
enum class DeviceConfig {
|
||||
X_ALIGNED,
|
||||
Y_ALIGNED_UNFOLDED,
|
||||
Y_ALIGNED_FOLDED
|
||||
Y_ALIGNED,
|
||||
}
|
||||
|
||||
private lateinit var deviceConfig: DeviceConfig
|
||||
@@ -143,6 +143,7 @@ class SideFpsControllerTest : SysuiTestCase() {
|
||||
|
||||
private fun testWithDisplay(
|
||||
deviceConfig: DeviceConfig = DeviceConfig.X_ALIGNED,
|
||||
isReverseDefaultRotation: Boolean = false,
|
||||
initInfo: DisplayInfo.() -> Unit = {},
|
||||
windowInsets: WindowInsets = insetsForSmallNavbar(),
|
||||
block: () -> Unit
|
||||
@@ -151,27 +152,21 @@ class SideFpsControllerTest : SysuiTestCase() {
|
||||
|
||||
when (deviceConfig) {
|
||||
DeviceConfig.X_ALIGNED -> {
|
||||
displayWidth = 2560
|
||||
displayHeight = 1600
|
||||
sensorLocation = SensorLocationInternal("", 2325, 0, 0)
|
||||
boundsWidth = 160
|
||||
boundsHeight = 84
|
||||
displayWidth = 3000
|
||||
displayHeight = 1500
|
||||
sensorLocation = SensorLocationInternal("", 2500, 0, 0)
|
||||
boundsWidth = 200
|
||||
boundsHeight = 100
|
||||
}
|
||||
DeviceConfig.Y_ALIGNED_UNFOLDED -> {
|
||||
displayWidth = 2208
|
||||
displayHeight = 1840
|
||||
sensorLocation = SensorLocationInternal("", 0, 510, 0)
|
||||
boundsWidth = 110
|
||||
boundsHeight = 210
|
||||
}
|
||||
DeviceConfig.Y_ALIGNED_FOLDED -> {
|
||||
displayWidth = 1080
|
||||
displayHeight = 2100
|
||||
sensorLocation = SensorLocationInternal("", 0, 590, 0)
|
||||
boundsWidth = 110
|
||||
boundsHeight = 210
|
||||
DeviceConfig.Y_ALIGNED -> {
|
||||
displayWidth = 2500
|
||||
displayHeight = 2000
|
||||
sensorLocation = SensorLocationInternal("", 0, 300, 0)
|
||||
boundsWidth = 100
|
||||
boundsHeight = 200
|
||||
}
|
||||
}
|
||||
|
||||
indicatorBounds = Rect(0, 0, boundsWidth, boundsHeight)
|
||||
displayBounds = Rect(0, 0, displayWidth, displayHeight)
|
||||
var locations = listOf(sensorLocation)
|
||||
@@ -194,8 +189,10 @@ class SideFpsControllerTest : SysuiTestCase() {
|
||||
|
||||
val displayInfo = DisplayInfo()
|
||||
displayInfo.initInfo()
|
||||
|
||||
val dmGlobal = mock(DisplayManagerGlobal::class.java)
|
||||
val display = Display(dmGlobal, DISPLAY_ID, displayInfo, DEFAULT_DISPLAY_ADJUSTMENTS)
|
||||
|
||||
whenEver(dmGlobal.getDisplayInfo(eq(DISPLAY_ID))).thenReturn(displayInfo)
|
||||
whenEver(windowManager.defaultDisplay).thenReturn(display)
|
||||
whenEver(windowManager.maximumWindowMetrics)
|
||||
@@ -203,9 +200,15 @@ class SideFpsControllerTest : SysuiTestCase() {
|
||||
whenEver(windowManager.currentWindowMetrics)
|
||||
.thenReturn(WindowMetrics(displayBounds, windowInsets))
|
||||
|
||||
val sideFpsControllerContext = context.createDisplayContext(display) as SysuiTestableContext
|
||||
sideFpsControllerContext.orCreateTestableResources.addOverride(
|
||||
com.android.internal.R.bool.config_reverseDefaultRotation,
|
||||
isReverseDefaultRotation
|
||||
)
|
||||
|
||||
sideFpsController =
|
||||
SideFpsController(
|
||||
context.createDisplayContext(display),
|
||||
sideFpsControllerContext,
|
||||
layoutInflater,
|
||||
fingerprintManager,
|
||||
windowManager,
|
||||
@@ -299,108 +302,316 @@ class SideFpsControllerTest : SysuiTestCase() {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun showsWithTaskbar() =
|
||||
testWithDisplay(deviceConfig = DeviceConfig.X_ALIGNED, { rotation = Surface.ROTATION_0 }) {
|
||||
hidesWithTaskbar(visible = true)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun showsWithTaskbarOnY() =
|
||||
fun showsSfpsIndicatorWithTaskbarForXAlignedSensor_0() =
|
||||
testWithDisplay(
|
||||
deviceConfig = DeviceConfig.Y_ALIGNED_UNFOLDED,
|
||||
deviceConfig = DeviceConfig.X_ALIGNED,
|
||||
isReverseDefaultRotation = false,
|
||||
{ rotation = Surface.ROTATION_0 }
|
||||
) { hidesWithTaskbar(visible = true) }
|
||||
) { verifySfpsIndicatorVisibilityOnTaskbarUpdate(sfpsViewVisible = true) }
|
||||
|
||||
@Test
|
||||
fun showsWithTaskbar90() =
|
||||
testWithDisplay(deviceConfig = DeviceConfig.X_ALIGNED, { rotation = Surface.ROTATION_90 }) {
|
||||
hidesWithTaskbar(visible = true)
|
||||
fun showsSfpsIndicatorWithTaskbarForXAlignedSensor_90() =
|
||||
testWithDisplay(
|
||||
deviceConfig = DeviceConfig.X_ALIGNED,
|
||||
isReverseDefaultRotation = false,
|
||||
{ rotation = Surface.ROTATION_90 }
|
||||
) { verifySfpsIndicatorVisibilityOnTaskbarUpdate(sfpsViewVisible = true) }
|
||||
|
||||
@Test
|
||||
fun showsSfpsIndicatorWithTaskbarForXAlignedSensor_180() =
|
||||
testWithDisplay(
|
||||
deviceConfig = DeviceConfig.X_ALIGNED,
|
||||
isReverseDefaultRotation = false,
|
||||
{ rotation = Surface.ROTATION_180 }
|
||||
) { verifySfpsIndicatorVisibilityOnTaskbarUpdate(sfpsViewVisible = true) }
|
||||
|
||||
@Test
|
||||
fun showsSfpsIndicatorWithTaskbarCollapsedDownForXAlignedSensor_180() =
|
||||
testWithDisplay(
|
||||
deviceConfig = DeviceConfig.X_ALIGNED,
|
||||
isReverseDefaultRotation = false,
|
||||
{ rotation = Surface.ROTATION_180 },
|
||||
windowInsets = insetsForSmallNavbar()
|
||||
) { verifySfpsIndicatorVisibilityOnTaskbarUpdate(sfpsViewVisible = true) }
|
||||
|
||||
@Test
|
||||
fun hidesSfpsIndicatorWhenOccludingTaskbarForXAlignedSensor_180() =
|
||||
testWithDisplay(
|
||||
deviceConfig = DeviceConfig.X_ALIGNED,
|
||||
isReverseDefaultRotation = false,
|
||||
{ rotation = Surface.ROTATION_180 },
|
||||
windowInsets = insetsForLargeNavbar()
|
||||
) { verifySfpsIndicatorVisibilityOnTaskbarUpdate(sfpsViewVisible = false) }
|
||||
|
||||
@Test
|
||||
fun showsSfpsIndicatorWithTaskbarForXAlignedSensor_270() =
|
||||
testWithDisplay(
|
||||
deviceConfig = DeviceConfig.X_ALIGNED,
|
||||
isReverseDefaultRotation = false,
|
||||
{ rotation = Surface.ROTATION_270 }
|
||||
) { verifySfpsIndicatorVisibilityOnTaskbarUpdate(sfpsViewVisible = true) }
|
||||
|
||||
@Test
|
||||
fun showsSfpsIndicatorWithTaskbarForXAlignedSensor_InReverseDefaultRotation_0() =
|
||||
testWithDisplay(
|
||||
deviceConfig = DeviceConfig.X_ALIGNED,
|
||||
isReverseDefaultRotation = true,
|
||||
{ rotation = Surface.ROTATION_0 }
|
||||
) { verifySfpsIndicatorVisibilityOnTaskbarUpdate(sfpsViewVisible = true) }
|
||||
|
||||
@Test
|
||||
fun showsSfpsIndicatorWithTaskbarForXAlignedSensor_InReverseDefaultRotation_90() =
|
||||
testWithDisplay(
|
||||
deviceConfig = DeviceConfig.X_ALIGNED,
|
||||
isReverseDefaultRotation = true,
|
||||
{ rotation = Surface.ROTATION_90 }
|
||||
) { verifySfpsIndicatorVisibilityOnTaskbarUpdate(sfpsViewVisible = true) }
|
||||
|
||||
@Test
|
||||
fun showsSfpsIndicatorWithTaskbarCollapsedDownForXAlignedSensor_InReverseDefaultRotation_90() =
|
||||
testWithDisplay(
|
||||
deviceConfig = DeviceConfig.X_ALIGNED,
|
||||
isReverseDefaultRotation = true,
|
||||
{ rotation = Surface.ROTATION_90 },
|
||||
windowInsets = insetsForSmallNavbar()
|
||||
) { verifySfpsIndicatorVisibilityOnTaskbarUpdate(sfpsViewVisible = true) }
|
||||
|
||||
@Test
|
||||
fun hidesSfpsIndicatorWhenOccludingTaskbarForXAlignedSensor_InReverseDefaultRotation_90() =
|
||||
testWithDisplay(
|
||||
deviceConfig = DeviceConfig.X_ALIGNED,
|
||||
isReverseDefaultRotation = true,
|
||||
{ rotation = Surface.ROTATION_90 },
|
||||
windowInsets = insetsForLargeNavbar()
|
||||
) { verifySfpsIndicatorVisibilityOnTaskbarUpdate(sfpsViewVisible = false) }
|
||||
|
||||
@Test
|
||||
fun showsSfpsIndicatorWithTaskbarForXAlignedSensor_InReverseDefaultRotation_180() =
|
||||
testWithDisplay(
|
||||
deviceConfig = DeviceConfig.X_ALIGNED,
|
||||
isReverseDefaultRotation = true,
|
||||
{ rotation = Surface.ROTATION_180 }
|
||||
) { verifySfpsIndicatorVisibilityOnTaskbarUpdate(sfpsViewVisible = true) }
|
||||
|
||||
@Test
|
||||
fun showsSfpsIndicatorWithTaskbarForXAlignedSensor_InReverseDefaultRotation_270() =
|
||||
testWithDisplay(
|
||||
deviceConfig = DeviceConfig.X_ALIGNED,
|
||||
isReverseDefaultRotation = true,
|
||||
{ rotation = Surface.ROTATION_270 }
|
||||
) { verifySfpsIndicatorVisibilityOnTaskbarUpdate(sfpsViewVisible = true) }
|
||||
|
||||
@Test
|
||||
fun showsSfpsIndicatorWithTaskbarForYAlignedSensor_0() =
|
||||
testWithDisplay(
|
||||
deviceConfig = DeviceConfig.Y_ALIGNED,
|
||||
isReverseDefaultRotation = false,
|
||||
{ rotation = Surface.ROTATION_0 }
|
||||
) { verifySfpsIndicatorVisibilityOnTaskbarUpdate(sfpsViewVisible = true) }
|
||||
|
||||
@Test
|
||||
fun showsSfpsIndicatorWithTaskbarForYAlignedSensor_90() =
|
||||
testWithDisplay(
|
||||
deviceConfig = DeviceConfig.Y_ALIGNED,
|
||||
isReverseDefaultRotation = false,
|
||||
{ rotation = Surface.ROTATION_90 }
|
||||
) { verifySfpsIndicatorVisibilityOnTaskbarUpdate(sfpsViewVisible = true) }
|
||||
|
||||
@Test
|
||||
fun showsSfpsIndicatorWithTaskbarForYAlignedSensor_180() =
|
||||
testWithDisplay(
|
||||
deviceConfig = DeviceConfig.Y_ALIGNED,
|
||||
isReverseDefaultRotation = false,
|
||||
{ rotation = Surface.ROTATION_180 },
|
||||
) {
|
||||
verifySfpsIndicatorVisibilityOnTaskbarUpdate(sfpsViewVisible = true)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun showsWithTaskbar90OnY() =
|
||||
fun showsSfpsIndicatorWithTaskbarForYAlignedSensor_270() =
|
||||
testWithDisplay(
|
||||
deviceConfig = DeviceConfig.Y_ALIGNED_UNFOLDED,
|
||||
{ rotation = Surface.ROTATION_90 }
|
||||
) { hidesWithTaskbar(visible = true) }
|
||||
|
||||
@Test
|
||||
fun showsWithTaskbar180() =
|
||||
testWithDisplay(
|
||||
deviceConfig = DeviceConfig.X_ALIGNED,
|
||||
{ rotation = Surface.ROTATION_180 }
|
||||
) { hidesWithTaskbar(visible = true) }
|
||||
|
||||
@Test
|
||||
fun showsWithTaskbar270OnY() =
|
||||
testWithDisplay(
|
||||
deviceConfig = DeviceConfig.Y_ALIGNED_UNFOLDED,
|
||||
deviceConfig = DeviceConfig.Y_ALIGNED,
|
||||
isReverseDefaultRotation = false,
|
||||
{ rotation = Surface.ROTATION_270 }
|
||||
) { hidesWithTaskbar(visible = true) }
|
||||
) { verifySfpsIndicatorVisibilityOnTaskbarUpdate(sfpsViewVisible = true) }
|
||||
|
||||
@Test
|
||||
fun showsWithTaskbarCollapsedDown() =
|
||||
fun showsSfpsIndicatorWithTaskbarCollapsedDownForYAlignedSensor_270() =
|
||||
testWithDisplay(
|
||||
deviceConfig = DeviceConfig.X_ALIGNED,
|
||||
deviceConfig = DeviceConfig.Y_ALIGNED,
|
||||
isReverseDefaultRotation = false,
|
||||
{ rotation = Surface.ROTATION_270 },
|
||||
windowInsets = insetsForSmallNavbar()
|
||||
) { hidesWithTaskbar(visible = true) }
|
||||
) { verifySfpsIndicatorVisibilityOnTaskbarUpdate(sfpsViewVisible = true) }
|
||||
|
||||
@Test
|
||||
fun showsWithTaskbarCollapsedDownOnY() =
|
||||
fun hidesSfpsIndicatorWhenOccludingTaskbarForYAlignedSensor_270() =
|
||||
testWithDisplay(
|
||||
deviceConfig = DeviceConfig.Y_ALIGNED_UNFOLDED,
|
||||
{ rotation = Surface.ROTATION_180 },
|
||||
windowInsets = insetsForSmallNavbar()
|
||||
) { hidesWithTaskbar(visible = true) }
|
||||
|
||||
@Test
|
||||
fun hidesWithTaskbarDown() =
|
||||
testWithDisplay(
|
||||
deviceConfig = DeviceConfig.X_ALIGNED,
|
||||
{ rotation = Surface.ROTATION_180 },
|
||||
windowInsets = insetsForLargeNavbar()
|
||||
) { hidesWithTaskbar(visible = false) }
|
||||
|
||||
@Test
|
||||
fun hidesWithTaskbarDownOnY() =
|
||||
testWithDisplay(
|
||||
deviceConfig = DeviceConfig.Y_ALIGNED_UNFOLDED,
|
||||
deviceConfig = DeviceConfig.Y_ALIGNED,
|
||||
isReverseDefaultRotation = false,
|
||||
{ rotation = Surface.ROTATION_270 },
|
||||
windowInsets = insetsForLargeNavbar()
|
||||
) { hidesWithTaskbar(visible = true) }
|
||||
) { verifySfpsIndicatorVisibilityOnTaskbarUpdate(sfpsViewVisible = false) }
|
||||
|
||||
private fun hidesWithTaskbar(visible: Boolean) {
|
||||
@Test
|
||||
fun showsSfpsIndicatorWithTaskbarForYAlignedSensor_InReverseDefaultRotation_0() =
|
||||
testWithDisplay(
|
||||
deviceConfig = DeviceConfig.Y_ALIGNED,
|
||||
isReverseDefaultRotation = true,
|
||||
{ rotation = Surface.ROTATION_0 }
|
||||
) { verifySfpsIndicatorVisibilityOnTaskbarUpdate(sfpsViewVisible = true) }
|
||||
|
||||
@Test
|
||||
fun showsSfpsIndicatorWithTaskbarForYAlignedSensor_InReverseDefaultRotation_90() =
|
||||
testWithDisplay(
|
||||
deviceConfig = DeviceConfig.Y_ALIGNED,
|
||||
isReverseDefaultRotation = true,
|
||||
{ rotation = Surface.ROTATION_90 },
|
||||
) {
|
||||
verifySfpsIndicatorVisibilityOnTaskbarUpdate(sfpsViewVisible = true)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun showsSfpsIndicatorWithTaskbarForYAlignedSensor_InReverseDefaultRotation_180() =
|
||||
testWithDisplay(
|
||||
deviceConfig = DeviceConfig.Y_ALIGNED,
|
||||
isReverseDefaultRotation = true,
|
||||
{ rotation = Surface.ROTATION_180 }
|
||||
) { verifySfpsIndicatorVisibilityOnTaskbarUpdate(sfpsViewVisible = true) }
|
||||
|
||||
@Test
|
||||
fun showsSfpsIndicatorWithTaskbarCollapsedDownForYAlignedSensor_InReverseDefaultRotation_180() =
|
||||
testWithDisplay(
|
||||
deviceConfig = DeviceConfig.Y_ALIGNED,
|
||||
isReverseDefaultRotation = true,
|
||||
{ rotation = Surface.ROTATION_180 },
|
||||
windowInsets = insetsForSmallNavbar()
|
||||
) { verifySfpsIndicatorVisibilityOnTaskbarUpdate(sfpsViewVisible = true) }
|
||||
|
||||
@Test
|
||||
fun hidesSfpsIndicatorWhenOccludingTaskbarForYAlignedSensor_InReverseDefaultRotation_180() =
|
||||
testWithDisplay(
|
||||
deviceConfig = DeviceConfig.Y_ALIGNED,
|
||||
isReverseDefaultRotation = true,
|
||||
{ rotation = Surface.ROTATION_180 },
|
||||
windowInsets = insetsForLargeNavbar()
|
||||
) { verifySfpsIndicatorVisibilityOnTaskbarUpdate(sfpsViewVisible = false) }
|
||||
|
||||
@Test
|
||||
fun showsSfpsIndicatorWithTaskbarForYAlignedSensor_InReverseDefaultRotation_270() =
|
||||
testWithDisplay(
|
||||
deviceConfig = DeviceConfig.Y_ALIGNED,
|
||||
isReverseDefaultRotation = true,
|
||||
{ rotation = Surface.ROTATION_270 }
|
||||
) { verifySfpsIndicatorVisibilityOnTaskbarUpdate(sfpsViewVisible = true) }
|
||||
|
||||
private fun verifySfpsIndicatorVisibilityOnTaskbarUpdate(sfpsViewVisible: Boolean) {
|
||||
sideFpsController.overlayOffsets = sensorLocation
|
||||
overlayController.show(SENSOR_ID, REASON_UNKNOWN)
|
||||
executor.runAllReady()
|
||||
|
||||
sideFpsController.overviewProxyListener.onTaskbarStatusUpdated(visible, false)
|
||||
sideFpsController.overviewProxyListener.onTaskbarStatusUpdated(true, false)
|
||||
executor.runAllReady()
|
||||
|
||||
verify(windowManager).addView(any(), any())
|
||||
verify(windowManager, never()).removeView(any())
|
||||
verify(sideFpsView).visibility = if (visible) View.VISIBLE else View.GONE
|
||||
verify(sideFpsView).visibility = if (sfpsViewVisible) View.VISIBLE else View.GONE
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link SideFpsController#updateOverlayParams} calculates indicator placement for ROTATION_0,
|
||||
* and uses RotateUtils.rotateBounds to map to the correct indicator location given the device
|
||||
* rotation. Assuming RotationUtils.rotateBounds works correctly, tests for indicator placement
|
||||
* in other rotations have been omitted.
|
||||
*/
|
||||
@Test
|
||||
fun testIndicatorPlacementForXAlignedSensor() =
|
||||
testWithDisplay(deviceConfig = DeviceConfig.X_ALIGNED) {
|
||||
overlayController.show(SENSOR_ID, REASON_UNKNOWN)
|
||||
fun verifiesIndicatorPlacementForXAlignedSensor_0() {
|
||||
testWithDisplay(
|
||||
deviceConfig = DeviceConfig.X_ALIGNED,
|
||||
isReverseDefaultRotation = false,
|
||||
{ rotation = Surface.ROTATION_0 }
|
||||
) {
|
||||
sideFpsController.overlayOffsets = sensorLocation
|
||||
|
||||
sideFpsController.updateOverlayParams(windowManager.defaultDisplay, indicatorBounds)
|
||||
|
||||
overlayController.show(SENSOR_ID, REASON_UNKNOWN)
|
||||
executor.runAllReady()
|
||||
|
||||
verify(windowManager).updateViewLayout(any(), overlayViewParamsCaptor.capture())
|
||||
|
||||
assertThat(overlayViewParamsCaptor.value.x).isEqualTo(sensorLocation.sensorLocationX)
|
||||
assertThat(overlayViewParamsCaptor.value.y).isEqualTo(0)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link SideFpsController#updateOverlayParams} calculates indicator placement for ROTATION_270
|
||||
* in reverse default rotation. It then uses RotateUtils.rotateBounds to map to the correct
|
||||
* indicator location given the device rotation. Assuming RotationUtils.rotateBounds works
|
||||
* correctly, tests for indicator placement in other rotations have been omitted.
|
||||
*/
|
||||
@Test
|
||||
fun testIndicatorPlacementForYAlignedSensor() =
|
||||
testWithDisplay(deviceConfig = DeviceConfig.Y_ALIGNED_UNFOLDED) {
|
||||
fun verifiesIndicatorPlacementForXAlignedSensor_InReverseDefaultRotation_270() {
|
||||
testWithDisplay(
|
||||
deviceConfig = DeviceConfig.X_ALIGNED,
|
||||
isReverseDefaultRotation = true,
|
||||
{ rotation = Surface.ROTATION_270 }
|
||||
) {
|
||||
sideFpsController.overlayOffsets = sensorLocation
|
||||
|
||||
sideFpsController.updateOverlayParams(windowManager.defaultDisplay, indicatorBounds)
|
||||
|
||||
overlayController.show(SENSOR_ID, REASON_UNKNOWN)
|
||||
executor.runAllReady()
|
||||
|
||||
verify(windowManager).updateViewLayout(any(), overlayViewParamsCaptor.capture())
|
||||
assertThat(overlayViewParamsCaptor.value.x).isEqualTo(sensorLocation.sensorLocationX)
|
||||
assertThat(overlayViewParamsCaptor.value.y).isEqualTo(0)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link SideFpsController#updateOverlayParams} calculates indicator placement for ROTATION_0,
|
||||
* and uses RotateUtils.rotateBounds to map to the correct indicator location given the device
|
||||
* rotation. Assuming RotationUtils.rotateBounds works correctly, tests for indicator placement
|
||||
* in other rotations have been omitted.
|
||||
*/
|
||||
@Test
|
||||
fun verifiesIndicatorPlacementForYAlignedSensor_0() =
|
||||
testWithDisplay(
|
||||
deviceConfig = DeviceConfig.Y_ALIGNED,
|
||||
isReverseDefaultRotation = false,
|
||||
{ rotation = Surface.ROTATION_0 }
|
||||
) {
|
||||
sideFpsController.overlayOffsets = sensorLocation
|
||||
|
||||
sideFpsController.updateOverlayParams(windowManager.defaultDisplay, indicatorBounds)
|
||||
|
||||
overlayController.show(SENSOR_ID, REASON_UNKNOWN)
|
||||
executor.runAllReady()
|
||||
|
||||
verify(windowManager).updateViewLayout(any(), overlayViewParamsCaptor.capture())
|
||||
assertThat(overlayViewParamsCaptor.value.x).isEqualTo(displayWidth - boundsWidth)
|
||||
assertThat(overlayViewParamsCaptor.value.y).isEqualTo(sensorLocation.sensorLocationY)
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link SideFpsController#updateOverlayParams} calculates indicator placement for ROTATION_270
|
||||
* in reverse default rotation. It then uses RotateUtils.rotateBounds to map to the correct
|
||||
* indicator location given the device rotation. Assuming RotationUtils.rotateBounds works
|
||||
* correctly, tests for indicator placement in other rotations have been omitted.
|
||||
*/
|
||||
@Test
|
||||
fun verifiesIndicatorPlacementForYAlignedSensor_InReverseDefaultRotation_270() =
|
||||
testWithDisplay(
|
||||
deviceConfig = DeviceConfig.Y_ALIGNED,
|
||||
isReverseDefaultRotation = true,
|
||||
{ rotation = Surface.ROTATION_270 }
|
||||
) {
|
||||
sideFpsController.overlayOffsets = sensorLocation
|
||||
|
||||
sideFpsController.updateOverlayParams(windowManager.defaultDisplay, indicatorBounds)
|
||||
|
||||
overlayController.show(SENSOR_ID, REASON_UNKNOWN)
|
||||
executor.runAllReady()
|
||||
|
||||
@@ -412,7 +623,6 @@ class SideFpsControllerTest : SysuiTestCase() {
|
||||
@Test
|
||||
fun hasSideFpsSensor_withSensorProps_returnsTrue() = testWithDisplay {
|
||||
// By default all those tests assume the side fps sensor is available.
|
||||
|
||||
assertThat(fingerprintManager.hasSideFpsSensor()).isTrue()
|
||||
}
|
||||
|
||||
@@ -425,7 +635,7 @@ class SideFpsControllerTest : SysuiTestCase() {
|
||||
|
||||
@Test
|
||||
fun testLayoutParams_isKeyguardDialogType() =
|
||||
testWithDisplay(deviceConfig = DeviceConfig.Y_ALIGNED_UNFOLDED) {
|
||||
testWithDisplay(deviceConfig = DeviceConfig.Y_ALIGNED) {
|
||||
sideFpsController.overlayOffsets = sensorLocation
|
||||
sideFpsController.updateOverlayParams(windowManager.defaultDisplay, indicatorBounds)
|
||||
overlayController.show(SENSOR_ID, REASON_UNKNOWN)
|
||||
@@ -440,7 +650,7 @@ class SideFpsControllerTest : SysuiTestCase() {
|
||||
|
||||
@Test
|
||||
fun testLayoutParams_hasNoMoveAnimationWindowFlag() =
|
||||
testWithDisplay(deviceConfig = DeviceConfig.Y_ALIGNED_UNFOLDED) {
|
||||
testWithDisplay(deviceConfig = DeviceConfig.Y_ALIGNED) {
|
||||
sideFpsController.overlayOffsets = sensorLocation
|
||||
sideFpsController.updateOverlayParams(windowManager.defaultDisplay, indicatorBounds)
|
||||
overlayController.show(SENSOR_ID, REASON_UNKNOWN)
|
||||
@@ -455,7 +665,7 @@ class SideFpsControllerTest : SysuiTestCase() {
|
||||
|
||||
@Test
|
||||
fun testLayoutParams_hasTrustedOverlayWindowFlag() =
|
||||
testWithDisplay(deviceConfig = DeviceConfig.Y_ALIGNED_UNFOLDED) {
|
||||
testWithDisplay(deviceConfig = DeviceConfig.Y_ALIGNED) {
|
||||
sideFpsController.overlayOffsets = sensorLocation
|
||||
sideFpsController.updateOverlayParams(windowManager.defaultDisplay, indicatorBounds)
|
||||
overlayController.show(SENSOR_ID, REASON_UNKNOWN)
|
||||
|
||||
Reference in New Issue
Block a user