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

Commit 9d555c41 authored by Jeff DeCew's avatar Jeff DeCew
Browse files

Fix System UI Tests so they don't read flags before setting them.

This is in preparation of using SetFlagsRule.ClassRule on SysuiTestCase
* Change many tests which construct fixtures during class initialization to use lazy instead.
* Change many tests to use @EnableFlags and @DisableFlags instead of the SetFlagsRule methods.
* Mark some tests as @BrokenWithSceneContainer which were only passing because of this error.

Fixes: 336768870
Flag: TEST_ONLY
Test: atest SystemUITests
Test: atest SystemUiRoboTests
Change-Id: Ie1bc2fead8c86f4a5b52b179e10fbbc1314d7ebc
parent 8d6962ab
Loading
Loading
Loading
Loading
+3 −6
Original line number Diff line number Diff line
@@ -66,15 +66,12 @@ class BouncerViewModelTest : SysuiTestCase() {

    private val kosmos = testKosmos()
    private val testScope = kosmos.testScope
    private val authenticationInteractor by lazy { kosmos.authenticationInteractor }
    private val bouncerInteractor by lazy { kosmos.bouncerInteractor }
    private val sceneContainerStartable = kosmos.sceneContainerStartable

    private lateinit var underTest: BouncerViewModel

    @Before
    fun setUp() {
        sceneContainerStartable.start()
        kosmos.sceneContainerStartable.start()
        underTest = kosmos.bouncerViewModel
    }

@@ -164,11 +161,11 @@ class BouncerViewModelTest : SysuiTestCase() {
            assertThat(isInputEnabled).isTrue()

            repeat(FakeAuthenticationRepository.MAX_FAILED_AUTH_TRIES_BEFORE_LOCKOUT) {
                bouncerInteractor.authenticate(WRONG_PIN)
                kosmos.bouncerInteractor.authenticate(WRONG_PIN)
            }
            assertThat(isInputEnabled).isFalse()

            val lockoutEndMs = authenticationInteractor.lockoutEndTimestamp ?: 0
            val lockoutEndMs = kosmos.authenticationInteractor.lockoutEndTimestamp ?: 0
            advanceTimeBy(lockoutEndMs - testScope.currentTime)
            assertThat(isInputEnabled).isTrue()
        }
+11 −9
Original line number Diff line number Diff line
@@ -60,17 +60,19 @@ class KeyguardInteractorTest : SysuiTestCase() {

    private val kosmos = testKosmos()
    private val testScope = kosmos.testScope
    private val repository = kosmos.fakeKeyguardRepository
    private val sceneInteractor = kosmos.sceneInteractor
    private val fromGoneTransitionInteractor = kosmos.fromGoneTransitionInteractor
    private val commandQueue = kosmos.fakeCommandQueue
    private val configRepository = kosmos.fakeConfigurationRepository
    private val bouncerRepository = kosmos.keyguardBouncerRepository
    private val shadeRepository = kosmos.shadeRepository
    private val keyguardTransitionRepository = kosmos.fakeKeyguardTransitionRepository
    private val repository by lazy { kosmos.fakeKeyguardRepository }
    private val sceneInteractor by lazy { kosmos.sceneInteractor }
    private val fromGoneTransitionInteractor by lazy { kosmos.fromGoneTransitionInteractor }
    private val commandQueue by lazy { kosmos.fakeCommandQueue }
    private val configRepository by lazy { kosmos.fakeConfigurationRepository }
    private val bouncerRepository by lazy { kosmos.keyguardBouncerRepository }
    private val shadeRepository by lazy { kosmos.shadeRepository }
    private val keyguardTransitionRepository by lazy { kosmos.fakeKeyguardTransitionRepository }

    private val transitionState: MutableStateFlow<ObservableTransitionState> =
        MutableStateFlow(ObservableTransitionState.Idle(Scenes.Gone))
    private val underTest = kosmos.keyguardInteractor

    private val underTest by lazy { kosmos.keyguardInteractor }

    @Before
    fun setUp() {
+2 −2
Original line number Diff line number Diff line
@@ -51,8 +51,8 @@ class NotificationsShadeSceneViewModelTest : SysuiTestCase() {

    private val kosmos = testKosmos()
    private val testScope = kosmos.testScope
    private val sceneInteractor = kosmos.sceneInteractor
    private val deviceUnlockedInteractor = kosmos.deviceUnlockedInteractor
    private val sceneInteractor by lazy { kosmos.sceneInteractor }
    private val deviceUnlockedInteractor by lazy { kosmos.deviceUnlockedInteractor }

    private val underTest = kosmos.notificationsShadeSceneViewModel

+4 −4
Original line number Diff line number Diff line
@@ -45,11 +45,11 @@ class SceneBackInteractorTest : SysuiTestCase() {

    private val kosmos = testKosmos()
    private val testScope = kosmos.testScope
    private val sceneInteractor = kosmos.sceneInteractor
    private val sceneContainerStartable = kosmos.sceneContainerStartable
    private val authenticationInteractor = kosmos.authenticationInteractor
    private val sceneInteractor by lazy { kosmos.sceneInteractor }
    private val sceneContainerStartable by lazy { kosmos.sceneContainerStartable }
    private val authenticationInteractor by lazy { kosmos.authenticationInteractor }

    private val underTest = kosmos.sceneBackInteractor
    private val underTest by lazy { kosmos.sceneBackInteractor }

    @Test
    @EnableSceneContainer
+3 −3
Original line number Diff line number Diff line
@@ -52,9 +52,9 @@ class PanelExpansionInteractorImplTest : SysuiTestCase() {

    private val kosmos = testKosmos()
    private val testScope = kosmos.testScope
    private val deviceUnlockedInteractor = kosmos.deviceUnlockedInteractor
    private val sceneInteractor = kosmos.sceneInteractor
    private val shadeAnimationInteractor = kosmos.shadeAnimationInteractor
    private val deviceUnlockedInteractor by lazy { kosmos.deviceUnlockedInteractor }
    private val sceneInteractor by lazy { kosmos.sceneInteractor }
    private val shadeAnimationInteractor by lazy { kosmos.shadeAnimationInteractor }
    private val transitionState =
        MutableStateFlow<ObservableTransitionState>(
            ObservableTransitionState.Idle(Scenes.Lockscreen)
Loading