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

Commit 0c973ce7 authored by Juan Sebastian Martinez's avatar Juan Sebastian Martinez
Browse files

Allowing clicks on the IDLE state of the QSLongPressEffect

When using Talkback, clicks are delivered upon a double tap on the
screen. These trigger the onTileClick path in QSLongPressEffect when the
effect is in the IDLE state. This is also a valid click and it is now
allowed in this state.

Test: atest SystemUiRoboTests:QSLongPressEffectTest
Flag: com.android.systemui.quick_settings_visual_haptics_longpress
Bug: 348295719
Change-Id: I12b8765fcc154b7d83ccf86e3a4ca33cca264644
parent 451652de
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -274,6 +274,29 @@ class QSLongPressEffectTest : SysuiTestCase() {
            assertThat(couldClick).isFalse()
        }

    @Test
    fun onTileClick_whileIdle_withQSTile_clicks() =
        testWhileInState(QSLongPressEffect.State.IDLE) {
            // GIVEN that a click was detected
            val couldClick = longPressEffect.onTileClick()

            // THEN the click is successful
            assertThat(couldClick).isTrue()
        }

    @Test
    fun onTileClick_whileIdle_withoutQSTile_cannotClick() =
        testWhileInState(QSLongPressEffect.State.IDLE) {
            // GIVEN that no QSTile has been set
            longPressEffect.qsTile = null

            // GIVEN that a click was detected
            val couldClick = longPressEffect.onTileClick()

            // THEN the click is not successful
            assertThat(couldClick).isFalse()
        }

    private fun testWithScope(initialize: Boolean = true, test: suspend TestScope.() -> Unit) =
        with(kosmos) {
            testScope.runTest {
+1 −1
Original line number Diff line number Diff line
@@ -160,7 +160,7 @@ constructor(
    }

    fun onTileClick(): Boolean {
        if (state == State.TIMEOUT_WAIT) {
        if (state == State.TIMEOUT_WAIT || state == State.IDLE) {
            setState(State.IDLE)
            qsTile?.let {
                it.click(expandable)