Loading packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardTransitionRepository.kt +1 −1 Original line number Diff line number Diff line Loading @@ -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 } Loading packages/SystemUI/tests/src/com/android/systemui/keyguard/data/repository/KeyguardTransitionRepositoryTest.kt +21 −29 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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 Loading @@ -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 { Loading Loading @@ -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( Loading @@ -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( Loading @@ -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 Loading Loading @@ -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 { Loading @@ -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" } Loading Loading
packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardTransitionRepository.kt +1 −1 Original line number Diff line number Diff line Loading @@ -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 } Loading
packages/SystemUI/tests/src/com/android/systemui/keyguard/data/repository/KeyguardTransitionRepositoryTest.kt +21 −29 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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 Loading @@ -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 { Loading Loading @@ -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( Loading @@ -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( Loading @@ -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 Loading Loading @@ -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 { Loading @@ -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" } Loading