Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c1bda788 authored by Brad Hinegardner's avatar Brad Hinegardner
Browse files

Remove need for isComplete, but still always send final animation value

Due to not using a SharedFlow anymore, there is a possibility for
collectors of this flow to not receive the final value due to the
outer-scoped isComplete value. The possibility of this increases
if there are multiple consumers of the same animation.

Removing isComplete removes this possibility. The final value will
now eventually show up to all consumers, but it is not guaranteed
to be arrive to all of them at the same time.

DistinctUntilChanged prevents the final value from being repeatedly
emitted to the consumers.

Bug: 318543679
Flag: NONE
Test: atest KeyguardTransitionAnimationFlowTest.kt
Test: manual - observe final values coming in to both shortcuts with keyguard_bottom_area_refactor flag turned on
Change-Id: I781f90cb80fcf58bec69c258a206ab717bdd2022
parent b1b2c84c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -94,7 +94,7 @@ class AlternateBouncerToAodTransitionViewModelTest : SysuiTestCase() {
                testScope,
            )

            assertThat(values.size).isEqualTo(6)
            assertThat(values.size).isEqualTo(5)
            values.forEach { assertThat(it).isIn(Range.closed(0f, 1f)) }
        }

+25 −3
Original line number Diff line number Diff line
@@ -54,6 +54,28 @@ class DreamingToLockscreenTransitionViewModelTest : SysuiTestCase() {
    private val fingerprintPropertyRepository = kosmos.fingerprintPropertyRepository
    private val underTest = kosmos.dreamingToLockscreenTransitionViewModel

    @Test
    fun shortcutsAlpha_bothShortcutsReceiveLastValue() =
        testScope.runTest {
            val valuesLeft by collectValues(underTest.shortcutsAlpha)
            val valuesRight by collectValues(underTest.shortcutsAlpha)

            keyguardTransitionRepository.sendTransitionSteps(
                listOf(
                    step(0f, TransitionState.STARTED),
                    step(0.3f),
                    step(0.5f),
                    step(0.6f),
                    step(0.8f),
                    step(1f),
                ),
                testScope,
            )

            assertThat(valuesLeft.last()).isEqualTo(1f)
            assertThat(valuesRight.last()).isEqualTo(1f)
        }

    @Test
    fun dreamOverlayTranslationY() =
        testScope.runTest {
@@ -73,7 +95,7 @@ class DreamingToLockscreenTransitionViewModelTest : SysuiTestCase() {
                testScope,
            )

            assertThat(values.size).isEqualTo(7)
            assertThat(values.size).isEqualTo(6)
            values.forEach { assertThat(it).isIn(Range.closed(0f, 100f)) }
        }

@@ -95,7 +117,7 @@ class DreamingToLockscreenTransitionViewModelTest : SysuiTestCase() {
                testScope,
            )

            assertThat(values.size).isEqualTo(4)
            assertThat(values.size).isEqualTo(3)
            values.forEach { assertThat(it).isIn(Range.closed(0f, 1f)) }
        }

@@ -210,7 +232,7 @@ class DreamingToLockscreenTransitionViewModelTest : SysuiTestCase() {
                testScope,
            )

            assertThat(values.size).isEqualTo(5)
            assertThat(values.size).isEqualTo(4)
            values.forEach { assertThat(it).isIn(Range.closed(-100f, 0f)) }
        }

+2 −2
Original line number Diff line number Diff line
@@ -61,7 +61,7 @@ class GoneToDreamingTransitionViewModelTest : SysuiTestCase() {

            // Only three values should be present, since the dream overlay runs for a small
            // fraction of the overall animation time
            assertThat(values.size).isEqualTo(5)
            assertThat(values.size).isEqualTo(4)
            values.forEach { assertThat(it).isIn(Range.closed(0f, 1f)) }
        }

@@ -84,7 +84,7 @@ class GoneToDreamingTransitionViewModelTest : SysuiTestCase() {
                testScope,
            )

            assertThat(values.size).isEqualTo(5)
            assertThat(values.size).isEqualTo(4)
            values.forEach { assertThat(it).isIn(Range.closed(0f, 100f)) }
        }

+3 −3
Original line number Diff line number Diff line
@@ -75,7 +75,7 @@ class LockscreenToDreamingTransitionViewModelTest : SysuiTestCase() {

            // Only three values should be present, since the dream overlay runs for a small
            // fraction of the overall animation time
            assertThat(values.size).isEqualTo(5)
            assertThat(values.size).isEqualTo(4)
            values.forEach { assertThat(it).isIn(Range.closed(0f, 1f)) }
        }

@@ -98,10 +98,10 @@ class LockscreenToDreamingTransitionViewModelTest : SysuiTestCase() {
                testScope = testScope,
            )

            assertThat(values.size).isEqualTo(6)
            assertThat(values.size).isEqualTo(5)
            values.forEach { assertThat(it).isIn(Range.closed(0f, 100f)) }
            // Validate finished value
            assertThat(values[5]).isEqualTo(0f)
            assertThat(values[4]).isEqualTo(0f)
        }

    @Test
+4 −4
Original line number Diff line number Diff line
@@ -76,7 +76,7 @@ class LockscreenToOccludedTransitionViewModelTest : SysuiTestCase() {
            )
            // Only 3 values should be present, since the dream overlay runs for a small fraction
            // of the overall animation time
            assertThat(values.size).isEqualTo(5)
            assertThat(values.size).isEqualTo(4)
            values.forEach { assertThat(it).isIn(Range.closed(0f, 1f)) }
        }

@@ -99,7 +99,7 @@ class LockscreenToOccludedTransitionViewModelTest : SysuiTestCase() {
                    ),
                testScope = testScope,
            )
            assertThat(values.size).isEqualTo(5)
            assertThat(values.size).isEqualTo(4)
            values.forEach { assertThat(it).isIn(Range.closed(0f, 100f)) }
        }

@@ -121,11 +121,11 @@ class LockscreenToOccludedTransitionViewModelTest : SysuiTestCase() {
                    ),
                testScope = testScope,
            )
            assertThat(values.size).isEqualTo(4)
            assertThat(values.size).isEqualTo(3)
            values.forEach { assertThat(it).isIn(Range.closed(0f, 100f)) }

            // Cancel will reset the translation
            assertThat(values[3]).isEqualTo(0)
            assertThat(values[2]).isEqualTo(0)
        }

    @Test
Loading