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

Commit bd5349dc authored by Helen Cheuk's avatar Helen Cheuk Committed by Android (Google) Code Review
Browse files

Merge "[Action Corner] Action of the same action corner state should not be...

Merge "[Action Corner] Action of the same action corner state should not be re-triggered after unlocking screen" into main
parents 87f95c5f 41fde92f
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ import org.junit.Before
import org.junit.runner.RunWith
import org.mockito.kotlin.mock
import org.mockito.kotlin.never
import org.mockito.kotlin.times
import org.mockito.kotlin.verify

@SmallTest
@@ -185,6 +186,26 @@ class ActionCornerInteractorTest : SysuiTestCase() {
        verify(launcherProxyService, never()).onActionCornerActivated(OVERVIEW, DEFAULT_DISPLAY)
    }

    @Test
    fun activeActionCorner_lockscreen_actionNotReTriggeredAfterUnlock() = unlockScreenAndRunTest {
        settingsRepository.setInt(ACTION_CORNER_BOTTOM_LEFT_ACTION, ACTION_CORNER_ACTION_OVERVIEW)
        actionCornerRepository.addState(ActiveActionCorner(BOTTOM_LEFT, DEFAULT_DISPLAY))

        setTransition(
            sceneTransition = Idle(Scenes.Lockscreen),
            stateTransition =
                TransitionStep(from = KeyguardState.GONE, to = KeyguardState.LOCKSCREEN),
        )
        setTransition(
            sceneTransition = Idle(Scenes.Gone),
            stateTransition =
                TransitionStep(from = KeyguardState.LOCKSCREEN, to = KeyguardState.GONE),
        )
        actionCornerRepository.addState(ActiveActionCorner(BOTTOM_LEFT, DEFAULT_DISPLAY))

        verify(launcherProxyService, times(1)).onActionCornerActivated(OVERVIEW, DEFAULT_DISPLAY)
    }

    private fun unlockScreenAndRunTest(testBody: suspend Kosmos.() -> Unit) =
        kosmos.runTest {
            setTransition(
+3 −1
Original line number Diff line number Diff line
@@ -79,11 +79,13 @@ constructor(
            }
            .flatMapLatest { shouldMonitorActionCorner ->
                if (shouldMonitorActionCorner) {
                    repository.actionCornerState.filterIsInstance<ActiveActionCorner>()
                    repository.actionCornerState
                } else {
                    emptyFlow()
                }
            }
            .distinctUntilChanged()
            .filterIsInstance<ActiveActionCorner>()
            .collect {
                val action = getAction(it.region)
                when (action) {