Merge "Fixing Y translation of media when no media is visible in previousLocation" into tm-qpr-dev

This commit is contained in:
Michał Brzeziński
2023-03-24 20:32:25 +00:00
committed by Android (Google) Code Review
2 changed files with 14 additions and 2 deletions

View File

@@ -317,13 +317,16 @@ constructor(
/** /**
* Returns the amount of translationY of the media container, during the current guided * Returns the amount of translationY of the media container, during the current guided
* transformation, if running. If there is no guided transformation running, it will return 0. * transformation, if running. If there is no guided transformation running, it will return -1.
*/ */
fun getGuidedTransformationTranslationY(): Int { fun getGuidedTransformationTranslationY(): Int {
if (!isCurrentlyInGuidedTransformation()) { if (!isCurrentlyInGuidedTransformation()) {
return -1 return -1
} }
val startHost = getHost(previousLocation) ?: return 0 val startHost = getHost(previousLocation)
if (startHost == null || !startHost.visible) {
return 0
}
return targetBounds.top - startHost.currentBounds.top return targetBounds.top - startHost.currentBounds.top
} }

View File

@@ -388,6 +388,15 @@ class MediaHierarchyManagerTest : SysuiTestCase() {
.isEqualTo(expectedTranslation) .isEqualTo(expectedTranslation)
} }
@Test
fun getGuidedTransformationTranslationY_previousHostInvisible_returnsZero() {
goToLockscreen()
enterGuidedTransformation()
whenever(lockHost.visible).thenReturn(false)
assertThat(mediaHierarchyManager.getGuidedTransformationTranslationY()).isEqualTo(0)
}
@Test @Test
fun isCurrentlyInGuidedTransformation_hostsVisible_returnsTrue() { fun isCurrentlyInGuidedTransformation_hostsVisible_returnsTrue() {
goToLockscreen() goToLockscreen()