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

Commit d0707f9c authored by Jiaming Cheng's avatar Jiaming Cheng
Browse files

[flexiglass] Fix AmbientCueInteractorTest failures with SceneContainerFlag

Also parameterized the test with the flexiglass flag.

Bug: 425347374
Flag: com.android.systemui.scene_container
Test: com.android.systemui.ambientcue.domain.interactor.AmbientCueInteractorTest
Change-Id: I5c01b70c3313996a8cade5d7d8430d8b0050a729
parent 02f51033
Loading
Loading
Loading
Loading
+46 −5
Original line number Diff line number Diff line
@@ -17,28 +17,51 @@
package com.android.systemui.ambientcue.domain.interactor

import android.content.applicationContext
import androidx.test.ext.junit.runners.AndroidJUnit4
import android.platform.test.flag.junit.FlagsParameterization
import androidx.test.filters.SmallTest
import com.android.compose.animation.scene.ObservableTransitionState
import com.android.systemui.SysuiTestCase
import com.android.systemui.ambientcue.data.repository.ambientCueRepository
import com.android.systemui.ambientcue.data.repository.fake
import com.android.systemui.ambientcue.shared.model.ActionModel
import com.android.systemui.ambientcue.shared.model.IconModel
import com.android.systemui.flags.andSceneContainer
import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository
import com.android.systemui.keyguard.shared.model.StatusBarState
import com.android.systemui.kosmos.collectLastValue
import com.android.systemui.kosmos.runCurrent
import com.android.systemui.kosmos.runTest
import com.android.systemui.res.R
import com.android.systemui.scene.domain.interactor.sceneInteractor
import com.android.systemui.scene.shared.flag.SceneContainerFlag
import com.android.systemui.scene.shared.model.Overlays
import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.shade.domain.interactor.enableDualShade
import com.android.systemui.testKosmos
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.flow.flowOf
import org.junit.Test
import org.junit.runner.RunWith
import platform.test.runner.parameterized.ParameterizedAndroidJunit4
import platform.test.runner.parameterized.Parameters

@RunWith(AndroidJUnit4::class)
@RunWith(ParameterizedAndroidJunit4::class)
@SmallTest
class AmbientCueInteractorTest : SysuiTestCase() {
class AmbientCueInteractorTest(flags: FlagsParameterization) : SysuiTestCase() {
    private val kosmos = testKosmos()

    companion object {
        @JvmStatic
        @Parameters(name = "{0}")
        fun getParams(): List<FlagsParameterization> {
            return FlagsParameterization.allCombinationsOf().andSceneContainer()
        }
    }

    init {
        mSetFlagsRule.setFlagsParameterization(flags)
    }

    @Test
    fun isDeactivated_setTrue_true() =
        kosmos.runTest {
@@ -149,8 +172,26 @@ class AmbientCueInteractorTest : SysuiTestCase() {
    fun isOccludedBySystemUi_whenExpandedShade_true() =
        kosmos.runTest {
            val isOccludedBySystemUi by collectLastValue(ambientCueInteractor.isOccludedBySystemUi)

            if (SceneContainerFlag.isEnabled) {
                enableDualShade()

                // Simulate the SceneInteractor being idle with the NotificationsShade overlay
                // present and Lockscreen as the underlying scene. This makes shadeExpansion > 0.
                sceneInteractor.setTransitionState(
                    flowOf(
                        ObservableTransitionState.Idle(
                            currentScene = Scenes.Lockscreen,
                            currentOverlays = setOf(Overlays.NotificationsShade),
                        )
                    )
                )
                runCurrent()
            } else {
                // SHADE_LOCKED forces the expansion to 1f in ShadeInteractor
                fakeKeyguardRepository.setStatusBarState(StatusBarState.SHADE_LOCKED)
            }

            assertThat(isOccludedBySystemUi).isTrue()
        }
}