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

Commit 456f7511 authored by Nick Chameyev's avatar Nick Chameyev
Browse files

[Unfold transition] Emit rotation change only if rotation changes

Currently, rotation change provider emits
rotation event on every display change which
causes unfold animation to force finish right
after unfolding.

Fixes: 358358963
Test: atest RotationChangeProviderTest
Flag: EXEMPT bugfix
Change-Id: I0252897608e083a2f814d5c0a57db16ca0d39110
parent 48cdc816
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ import org.mockito.Captor
import org.mockito.Mock
import org.mockito.Mockito.spy
import org.mockito.Mockito.verify
import org.mockito.Mockito.inOrder
import org.mockito.Mockito.verifyNoMoreInteractions
import org.mockito.MockitoAnnotations

@@ -78,6 +79,26 @@ class RotationChangeProviderTest : SysuiTestCase() {
        verify(listener).onRotationChanged(42)
    }

    @Test
    fun onRotationChanged_rotationSentMultipleWithTheSameValue_listenerReceivesUpdateOnce() {
        sendRotationUpdate(42)
        sendRotationUpdate(42)
        sendRotationUpdate(42)

        verify(listener).onRotationChanged(42)
    }

    @Test
    fun onRotationChanged_rotationSentMultipleTimesWithDifferentValues_listenerReceivesUpdates() {
        sendRotationUpdate(0)
        sendRotationUpdate(1)

        with(inOrder(listener)) {
            verify(listener).onRotationChanged(0)
            verify(listener).onRotationChanged(1)
        }
    }

    @Test
    fun onRotationChanged_subscribersRemoved_noRotationChangeReceived() {
        sendRotationUpdate(42)
+1 −1
Original line number Diff line number Diff line
@@ -103,7 +103,7 @@ constructor(

                if (displayId == display.displayId) {
                    val currentRotation = display.rotation
                    if (lastRotation.compareAndSet(lastRotation.get(), currentRotation)) {
                    if (lastRotation.getAndSet(currentRotation) != currentRotation) {
                        listeners.forEach { it.onRotationChanged(currentRotation) }
                    }
                }