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

Commit ba682449 authored by Matt Pietal's avatar Matt Pietal Committed by Android (Google) Code Review
Browse files

Merge "Remove log wtf from transitions" into main

parents 33f8b40d 966e9611
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -285,7 +285,7 @@ constructor(
        state: TransitionState
    ) {
        if (updateTransitionId != transitionId) {
            Log.wtf(TAG, "Attempting to update with old/invalid transitionId: $transitionId")
            Log.e(TAG, "Attempting to update with old/invalid transitionId: $transitionId")
            return
        }

+21 −29
Original line number Diff line number Diff line
@@ -17,9 +17,6 @@
package com.android.systemui.keyguard.data.repository

import android.animation.ValueAnimator
import android.util.Log
import android.util.Log.TerribleFailure
import android.util.Log.TerribleFailureHandler
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.FlakyTest
import androidx.test.filters.SmallTest
@@ -53,7 +50,6 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.test.advanceTimeBy
import kotlinx.coroutines.test.runCurrent
import kotlinx.coroutines.test.runTest
import org.junit.After
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
@@ -67,23 +63,14 @@ class KeyguardTransitionRepositoryTest : SysuiTestCase() {
    private val testScope = kosmos.testScope

    private lateinit var underTest: KeyguardTransitionRepository
    private lateinit var oldWtfHandler: TerribleFailureHandler
    private lateinit var wtfHandler: WtfHandler
    private lateinit var runner: KeyguardTransitionRunner

    @Before
    fun setUp() {
        underTest = KeyguardTransitionRepositoryImpl(Dispatchers.Main)
        wtfHandler = WtfHandler()
        oldWtfHandler = Log.setWtfHandler(wtfHandler)
        runner = KeyguardTransitionRunner(underTest)
    }

    @After
    fun tearDown() {
        oldWtfHandler?.let { Log.setWtfHandler(it) }
    }

    @Test
    fun startTransitionRunsAnimatorToCompletion() =
        testScope.runTest {
@@ -333,15 +320,17 @@ class KeyguardTransitionRepositoryTest : SysuiTestCase() {
        }

    @Test
    fun attemptTomanuallyUpdateTransitionWithInvalidUUIDthrowsException() =
    fun attemptTomanuallyUpdateTransitionWithInvalidUUIDEmitsNothing() =
        testScope.runTest {
            val steps by collectValues(underTest.transitions.dropWhile { step -> step.from == OFF })
            underTest.updateTransition(UUID.randomUUID(), 0f, TransitionState.RUNNING)
            assertThat(wtfHandler.failed).isTrue()
            assertThat(steps.size).isEqualTo(0)
        }

    @Test
    fun attemptToManuallyUpdateTransitionAfterFINISHEDstateThrowsException() =
    fun attemptToManuallyUpdateTransitionAfterFINISHEDstateEmitsNothing() =
        testScope.runTest {
            val steps by collectValues(underTest.transitions.dropWhile { step -> step.from == OFF })
            val uuid =
                underTest.startTransition(
                    TransitionInfo(
@@ -356,12 +345,19 @@ class KeyguardTransitionRepositoryTest : SysuiTestCase() {
                underTest.updateTransition(it, 1f, TransitionState.FINISHED)
                underTest.updateTransition(it, 0.5f, TransitionState.RUNNING)
            }
            assertThat(wtfHandler.failed).isTrue()
            assertThat(steps.size).isEqualTo(2)
            assertThat(steps[0])
                .isEqualTo(TransitionStep(AOD, LOCKSCREEN, 0f, TransitionState.STARTED, OWNER_NAME))
            assertThat(steps[1])
                .isEqualTo(
                    TransitionStep(AOD, LOCKSCREEN, 1f, TransitionState.FINISHED, OWNER_NAME)
                )
        }

    @Test
    fun attemptToManuallyUpdateTransitionAfterCANCELEDstateThrowsException() =
    fun attemptToManuallyUpdateTransitionAfterCANCELEDstateEmitsNothing() =
        testScope.runTest {
            val steps by collectValues(underTest.transitions.dropWhile { step -> step.from == OFF })
            val uuid =
                underTest.startTransition(
                    TransitionInfo(
@@ -376,7 +372,13 @@ class KeyguardTransitionRepositoryTest : SysuiTestCase() {
                underTest.updateTransition(it, 0.2f, TransitionState.CANCELED)
                underTest.updateTransition(it, 0.5f, TransitionState.RUNNING)
            }
            assertThat(wtfHandler.failed).isTrue()
            assertThat(steps.size).isEqualTo(2)
            assertThat(steps[0])
                .isEqualTo(TransitionStep(AOD, LOCKSCREEN, 0f, TransitionState.STARTED, OWNER_NAME))
            assertThat(steps[1])
                .isEqualTo(
                    TransitionStep(AOD, LOCKSCREEN, 0.2f, TransitionState.CANCELED, OWNER_NAME)
                )
        }

    @Test
@@ -530,8 +532,6 @@ class KeyguardTransitionRepositoryTest : SysuiTestCase() {
            }
        assertThat(steps[steps.size - 1])
            .isEqualTo(TransitionStep(from, to, lastValue, status, OWNER_NAME))

        assertThat(wtfHandler.failed).isFalse()
    }

    private fun getAnimator(): ValueAnimator {
@@ -541,14 +541,6 @@ class KeyguardTransitionRepositoryTest : SysuiTestCase() {
        }
    }

    private class WtfHandler : TerribleFailureHandler {
        var failed = false

        override fun onTerribleFailure(tag: String, what: TerribleFailure, system: Boolean) {
            failed = true
        }
    }

    companion object {
        private const val OWNER_NAME = "KeyguardTransitionRunner"
    }