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

Commit fdca8b49 authored by William Xiao's avatar William Xiao
Browse files

Remove ViewUtils calls from KeyguardStatusBarViewControllerTest

These no longer appear to be necessary with recent changes to the test
and seem to have the potential to cause ANRs.

Bug: 419321603
Test: atest KeyguardStatusBarViewControllerTest
Flag: NONE test fix
Change-Id: I992127b0684d6a4dd2b91900d497c72c4a66478e
parent 961ec3ea
Loading
Loading
Loading
Loading
+192 −285
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@ import android.platform.test.annotations.EnableFlags
import android.provider.Settings
import android.testing.TestableLooper
import android.testing.TestableLooper.RunWithLooper
import android.testing.ViewUtils
import android.view.LayoutInflater
import android.view.View
import androidx.test.ext.junit.runners.AndroidJUnit4
@@ -90,7 +89,6 @@ import kotlinx.coroutines.test.runCurrent
import kotlinx.coroutines.test.runTest
import org.junit.Assert
import org.junit.Before
import org.junit.Ignore
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.ArgumentCaptor
@@ -508,7 +506,6 @@ class KeyguardStatusBarViewControllerTest : SysuiTestCase() {
        assertThat(keyguardStatusBarView.visibility).isEqualTo(View.VISIBLE)
    }

    @Ignore("b/419321603")
    @Test
    @DisableSceneContainer
    fun updateViewState_panelExpandedHeightZero_viewHidden() {
@@ -846,38 +843,27 @@ class KeyguardStatusBarViewControllerTest : SysuiTestCase() {
        assertThat(keyguardStatusBarView.visibility).isEqualTo(View.INVISIBLE)
    }

    @Ignore("b/425280318")
    @DisableSceneContainer
    @DisableFlags(Flags.FLAG_GLANCEABLE_HUB_V2)
    fun animateToGlanceableHub_v2Disabled_affectsAlpha() =
        testScope.runTest {
            try {
            controller.init()
            val transitionAlphaAmount = .5f
                ViewUtils.attachView(keyguardStatusBarView)

                looper.processAllMessages()
            updateStateToKeyguard()
            kosmos.fakeCommunalSceneRepository.instantlyTransitionTo(CommunalScenes.Communal)
            runCurrent()
            controller.updateCommunalAlphaTransition(transitionAlphaAmount)
            assertThat(keyguardStatusBarView.visibility).isEqualTo(View.VISIBLE)
            assertThat(keyguardStatusBarView.alpha).isEqualTo(transitionAlphaAmount)
            } finally {
                ViewUtils.detachView(keyguardStatusBarView)
            }
        }

    @Ignore("b/425280318")
    @DisableSceneContainer
    @DisableFlags(Flags.FLAG_GLANCEABLE_HUB_V2)
    fun animateToGlanceableHub_v2Disabled_alphaResetOnCommunalNotShowing() =
        testScope.runTest {
            try {
            controller.init()
                ViewUtils.attachView(keyguardStatusBarView)

                looper.processAllMessages()
            updateStateToKeyguard()

            // Verify status bar is fully visible on lockscreen
@@ -896,9 +882,6 @@ class KeyguardStatusBarViewControllerTest : SysuiTestCase() {
            runCurrent()
            assertThat(keyguardStatusBarView.visibility).isEqualTo(View.VISIBLE)
            assertThat(keyguardStatusBarView.alpha).isNotEqualTo(.5f)
            } finally {
                ViewUtils.detachView(keyguardStatusBarView)
            }
        }

    @Test
@@ -906,10 +889,7 @@ class KeyguardStatusBarViewControllerTest : SysuiTestCase() {
    @DisableFlags(Flags.FLAG_GLANCEABLE_HUB_V2)
    fun statusBar_isHidden_goneToGlanceableHubV2Disabled() =
        testScope.runTest {
            try {
            controller.init()
                ViewUtils.attachView(keyguardStatusBarView)
                looper.processAllMessages()

            // Keyguard is showing and start transitioning to communal
            updateStateToKeyguard()
@@ -921,10 +901,7 @@ class KeyguardStatusBarViewControllerTest : SysuiTestCase() {
                    goneToGlanceableHubTransitionStep(0.0f, STARTED),
                    goneToGlanceableHubTransitionStep(.1f),
                )
                kosmos.fakeKeyguardTransitionRepository.sendTransitionSteps(
                    transitionSteps,
                    testScope,
                )
            kosmos.fakeKeyguardTransitionRepository.sendTransitionSteps(transitionSteps, testScope)

            // Verify status bar is not visible
            assertThat(keyguardStatusBarView.alpha).isEqualTo(0f)
@@ -940,9 +917,6 @@ class KeyguardStatusBarViewControllerTest : SysuiTestCase() {

            assertThat(keyguardStatusBarView.alpha).isEqualTo(0f)
            assertThat(keyguardStatusBarView.visibility).isEqualTo(View.INVISIBLE)
            } finally {
                ViewUtils.detachView(keyguardStatusBarView)
            }
        }

    @Test
@@ -950,10 +924,7 @@ class KeyguardStatusBarViewControllerTest : SysuiTestCase() {
    @EnableFlags(Flags.FLAG_GLANCEABLE_HUB_V2)
    fun statusBar_fullyVisible_goneToGlanceableHubV2Enabled() =
        testScope.runTest {
            try {
            controller.init()
                ViewUtils.attachView(keyguardStatusBarView)
                looper.processAllMessages()

            // Keyguard is showing and start transitioning to communal
            updateStateToKeyguard()
@@ -986,9 +957,6 @@ class KeyguardStatusBarViewControllerTest : SysuiTestCase() {

            assertThat(keyguardStatusBarView.alpha).isEqualTo(1f)
            assertThat(keyguardStatusBarView.visibility).isEqualTo(View.VISIBLE)
            } finally {
                ViewUtils.detachView(keyguardStatusBarView)
            }
        }

    @Test
@@ -996,11 +964,8 @@ class KeyguardStatusBarViewControllerTest : SysuiTestCase() {
    @DisableFlags(Flags.FLAG_GLANCEABLE_HUB_V2)
    fun dragDownShadeOverGlanceableHub_v2Disabled_alphaRemainsZero() =
        testScope.runTest {
            try {
            controller.init()
                ViewUtils.attachView(keyguardStatusBarView)

                looper.processAllMessages()
            updateStateToKeyguard()

            // Verify status bar is fully visible on lockscreen
@@ -1019,21 +984,14 @@ class KeyguardStatusBarViewControllerTest : SysuiTestCase() {
            controller.updateViewState()
            assertThat(keyguardStatusBarView.visibility).isEqualTo(View.INVISIBLE)
            assertThat(keyguardStatusBarView.alpha).isEqualTo(0f)
            } finally {
                ViewUtils.detachView(keyguardStatusBarView)
            }
        }

    @Ignore("b/425280318")
    @DisableSceneContainer
    @EnableFlags(Flags.FLAG_GLANCEABLE_HUB_V2)
    fun animateToGlanceableHub_v2Enabled_alphaDoesNotChange() =
        testScope.runTest {
            try {
            controller.init()
                ViewUtils.attachView(keyguardStatusBarView)

                looper.processAllMessages()
            updateStateToKeyguard()

            // Verify status bar is fully visible on lockscreen
@@ -1045,19 +1003,13 @@ class KeyguardStatusBarViewControllerTest : SysuiTestCase() {
            runCurrent()
            assertThat(keyguardStatusBarView.visibility).isEqualTo(View.VISIBLE)
            assertThat(keyguardStatusBarView.alpha).isEqualTo(1f)
            } finally {
                ViewUtils.detachView(keyguardStatusBarView)
            }
        }

    @Test
    @DisableSceneContainer
    fun lockscreenToDreaming_affectsAlpha() =
        testScope.runTest {
            try {
            controller.init()
                ViewUtils.attachView(keyguardStatusBarView)
                looper.processAllMessages()
            updateStateToKeyguard()

            val transitionSteps =
@@ -1065,10 +1017,7 @@ class KeyguardStatusBarViewControllerTest : SysuiTestCase() {
                    lockscreenToDreamTransitionStep(0.0f, STARTED),
                    lockscreenToDreamTransitionStep(.1f),
                )
                kosmos.fakeKeyguardTransitionRepository.sendTransitionSteps(
                    transitionSteps,
                    testScope,
                )
            kosmos.fakeKeyguardTransitionRepository.sendTransitionSteps(transitionSteps, testScope)

            assertThat(keyguardStatusBarView.alpha).isIn(Range.open(0f, 1f))
            assertThat(keyguardStatusBarView.visibility).isEqualTo(View.VISIBLE)
@@ -1083,19 +1032,13 @@ class KeyguardStatusBarViewControllerTest : SysuiTestCase() {

            assertThat(keyguardStatusBarView.alpha).isEqualTo(0f)
            assertThat(keyguardStatusBarView.visibility).isEqualTo(View.INVISIBLE)
            } finally {
                ViewUtils.detachView(keyguardStatusBarView)
            }
        }

    @Test
    @DisableSceneContainer
    fun dreamingToLockscreen_affectsAlpha() =
        testScope.runTest {
            try {
            controller.init()
                ViewUtils.attachView(keyguardStatusBarView)
                looper.processAllMessages()
            updateStateToKeyguard()

            val transitionSteps =
@@ -1103,26 +1046,17 @@ class KeyguardStatusBarViewControllerTest : SysuiTestCase() {
                    dreamToLockscreenTransitionStep(0.0f, STARTED),
                    dreamToLockscreenTransitionStep(.3f),
                )
                kosmos.fakeKeyguardTransitionRepository.sendTransitionSteps(
                    transitionSteps,
                    testScope,
                )
            kosmos.fakeKeyguardTransitionRepository.sendTransitionSteps(transitionSteps, testScope)

            assertThat(keyguardStatusBarView.alpha).isIn(Range.open(0f, 1f))
            assertThat(keyguardStatusBarView.visibility).isEqualTo(View.VISIBLE)
            } finally {
                ViewUtils.detachView(keyguardStatusBarView)
            }
        }

    @Test
    @DisableSceneContainer
    fun dreamingToLockscreen_resetAlphaOnFinished() =
        testScope.runTest {
            try {
            controller.init()
                ViewUtils.attachView(keyguardStatusBarView)
                looper.processAllMessages()
            updateStateToKeyguard()

            val transitionSteps =
@@ -1130,10 +1064,7 @@ class KeyguardStatusBarViewControllerTest : SysuiTestCase() {
                    dreamToLockscreenTransitionStep(0.0f, STARTED),
                    dreamToLockscreenTransitionStep(.3f),
                )
                kosmos.fakeKeyguardTransitionRepository.sendTransitionSteps(
                    transitionSteps,
                    testScope,
                )
            kosmos.fakeKeyguardTransitionRepository.sendTransitionSteps(transitionSteps, testScope)

            val explicitAlpha = keyguardStatusBarView.alpha
            assertThat(explicitAlpha).isIn(Range.open(0f, 1f))
@@ -1145,43 +1076,28 @@ class KeyguardStatusBarViewControllerTest : SysuiTestCase() {

            assertThat(keyguardStatusBarView.alpha).isNotEqualTo(explicitAlpha)
            assertThat(keyguardStatusBarView.visibility).isEqualTo(View.VISIBLE)
            } finally {
                ViewUtils.detachView(keyguardStatusBarView)
            }
        }

    @Test
    @DisableSceneContainer
    fun goneToDreaming_affectsAlpha() =
        testScope.runTest {
            try {
            controller.init()
                ViewUtils.attachView(keyguardStatusBarView)
                looper.processAllMessages()
            updateStateToKeyguard()

            val transitionSteps =
                listOf(goneToDreamTransitionStep(0.0f, STARTED), goneToDreamTransitionStep(.1f))
                kosmos.fakeKeyguardTransitionRepository.sendTransitionSteps(
                    transitionSteps,
                    testScope,
                )
            kosmos.fakeKeyguardTransitionRepository.sendTransitionSteps(transitionSteps, testScope)

            assertThat(keyguardStatusBarView.alpha).isEqualTo(0f)
            assertThat(keyguardStatusBarView.visibility).isEqualTo(View.INVISIBLE)
            } finally {
                ViewUtils.detachView(keyguardStatusBarView)
            }
        }

    @Test
    @DisableSceneContainer
    fun resetAlpha_onTransitionToDreamingInterrupted() =
        testScope.runTest {
            try {
            controller.init()
                ViewUtils.attachView(keyguardStatusBarView)
                looper.processAllMessages()
            updateStateToKeyguard()

            // Transition to dreaming
@@ -1190,10 +1106,7 @@ class KeyguardStatusBarViewControllerTest : SysuiTestCase() {
                    lockscreenToDreamTransitionStep(0.0f, STARTED),
                    lockscreenToDreamTransitionStep(.1f),
                )
                kosmos.fakeKeyguardTransitionRepository.sendTransitionSteps(
                    transitionSteps,
                    testScope,
                )
            kosmos.fakeKeyguardTransitionRepository.sendTransitionSteps(transitionSteps, testScope)

            val explicitAlphaByDream = keyguardStatusBarView.alpha
            assertThat(keyguardStatusBarView.visibility).isEqualTo(View.VISIBLE)
@@ -1207,16 +1120,10 @@ class KeyguardStatusBarViewControllerTest : SysuiTestCase() {
                    dreamToAodTransitionStep(.5f),
                    dreamToAodTransitionStep(1f, FINISHED),
                )
                kosmos.fakeKeyguardTransitionRepository.sendTransitionSteps(
                    transitionSteps,
                    testScope,
                )
            kosmos.fakeKeyguardTransitionRepository.sendTransitionSteps(transitionSteps, testScope)

            assertThat(keyguardStatusBarView.alpha).isNotEqualTo(explicitAlphaByDream)
            assertThat(keyguardStatusBarView.visibility).isEqualTo(View.INVISIBLE)
            } finally {
                ViewUtils.detachView(keyguardStatusBarView)
            }
        }

    /**