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

Commit 484792a1 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Allowing state logic to progress from terminal states on touch down." into main

parents 9d5664ed 9991ab22
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -111,6 +111,26 @@ class QSLongPressEffectTest : SysuiTestCase() {
        assertThat(longPressEffect.state).isEqualTo(QSLongPressEffect.State.TIMEOUT_WAIT)
    }

    @Test
    fun onActionDown_whileClicked_startsWait() =
        testWhileInState(QSLongPressEffect.State.CLICKED) {
            // GIVEN an action down event occurs
            longPressEffect.handleActionDown()

            // THEN the effect moves to the TIMEOUT_WAIT state
            assertThat(longPressEffect.state).isEqualTo(QSLongPressEffect.State.TIMEOUT_WAIT)
        }

    @Test
    fun onActionDown_whileLongClicked_startsWait() =
        testWhileInState(QSLongPressEffect.State.LONG_CLICKED) {
            // GIVEN an action down event occurs
            longPressEffect.handleActionDown()

            // THEN the effect moves to the TIMEOUT_WAIT state
            assertThat(longPressEffect.state).isEqualTo(QSLongPressEffect.State.TIMEOUT_WAIT)
        }

    @Test
    fun onActionCancel_whileWaiting_goesIdle() =
        testWhileInState(QSLongPressEffect.State.TIMEOUT_WAIT) {
+5 −1
Original line number Diff line number Diff line
@@ -107,7 +107,11 @@ constructor(
    fun handleActionDown() {
        logEvent(qsTile?.tileSpec, state, "action down received")
        when (state) {
            State.IDLE -> {
            State.IDLE,
            // ACTION_DOWN typically only happens in State.IDLE but including CLICKED and
            // LONG_CLICKED just to be safe`b
            State.CLICKED,
            State.LONG_CLICKED -> {
                setState(State.TIMEOUT_WAIT)
            }
            State.RUNNING_BACKWARDS_FROM_UP,