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

Commit f9887246 authored by Behnam Heydarshahi's avatar Behnam Heydarshahi
Browse files

Factor in overscroll in compose force QS expansion tests

We have a flag that prevents QS expansion on overscroll. We updated a
test class to consider overscroll when determining the expected
expansion value.

Flag: com.android.systemui.no_expansion_on_overscroll
Bug: 414346597
Test: atest QSFragmentComposeViewModelForceQSTest
Change-Id: I2fcfb14dd1a91da8871108a512e96cad86581c74
parent ecb3cb27
Loading
Loading
Loading
Loading
+32 −0
Original line number Diff line number Diff line
@@ -16,8 +16,11 @@

package com.android.systemui.qs.composefragment.viewmodel

import android.platform.test.annotations.DisableFlags
import android.platform.test.annotations.EnableFlags
import android.testing.TestableLooper.RunWithLooper
import androidx.test.filters.SmallTest
import com.android.systemui.Flags
import com.android.systemui.deviceentry.data.repository.fakeDeviceEntryBypassRepository
import com.android.systemui.kosmos.testScope
import com.android.systemui.statusbar.StatusBarState
@@ -35,6 +38,7 @@ import platform.test.runner.parameterized.Parameters
class QSFragmentComposeViewModelForceQSTest(private val testData: TestData) :
    AbstractQSFragmentComposeViewModelTest() {

    @DisableFlags(Flags.FLAG_NO_EXPANSION_ON_OVERSCROLL)
    @Test
    fun forceQs_orRealExpansion() =
        with(kosmos) {
@@ -56,6 +60,34 @@ class QSFragmentComposeViewModelForceQSTest(private val testData: TestData) :
            }
        }

    @EnableFlags(Flags.FLAG_NO_EXPANSION_ON_OVERSCROLL)
    @Test
    fun forceQs_orRealExpansion_withNoExpansionOnOverscroll() =
        with(kosmos) {
            testScope.testWithinLifecycle {
                with(testData) {
                    sysuiStatusBarStateController.setState(statusBarState)
                    underTest.isQsExpanded = expanded
                    underTest.isStackScrollerOverscrolling = stackScrollerOverScrolling
                    fakeDeviceEntryBypassRepository.setBypassEnabled(bypassEnabled)
                    underTest.isTransitioningToFullShade = transitioningToFullShade
                    underTest.isInSplitShade = inSplitShade

                    underTest.setQsExpansionValue(EXPANSION)

                    runCurrent()
                    assertThat(underTest.expansionState.progress)
                        .isEqualTo(
                            if (expectedForceQS) {
                                1f
                            } else {
                                if (stackScrollerOverScrolling) 0 else EXPANSION
                            }
                        )
                }
            }
        }

    data class TestData(
        val statusBarState: Int,
        val expanded: Boolean,