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

Commit 220ea093 authored by Fabian Kozynski's avatar Fabian Kozynski
Browse files

Fix || for != in QSTileViewImpl

The block to change colors should only be ran if the colors actually
need to change. The condition was wrongly written, but because those
variables are boolean, the only effect it had was that it would be
called more often (sometimes when colors didn't need to change).

Test: atest QSTileViewImpl
Fixes: 271835100
Change-Id: Idd160b31b72cb18b8d90aa48133dc425a414c697
parent e50a62e3
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -490,7 +490,7 @@ open class QSTileViewImpl @JvmOverloads constructor(
        }

        // Colors
        if (state.state != lastState || state.disabledByPolicy || lastDisabledByPolicy) {
        if (state.state != lastState || state.disabledByPolicy != lastDisabledByPolicy) {
            singleAnimator.cancel()
            mQsLogger?.logTileBackgroundColorUpdateIfInternetTile(
                    state.spec,
+20 −0
Original line number Diff line number Diff line
@@ -316,6 +316,26 @@ class QSTileViewImplTest : SysuiTestCase() {
        assertThat(colorsDisabledByPolicy).containsExactlyElementsIn(colorsUnavailable)
    }

    @Test
    fun testDisableByPolicyThenRemoved_changesColor() {
        val stateActive = QSTile.State()
        stateActive.state = Tile.STATE_ACTIVE

        val stateDisabledByPolicy = stateActive.copy()
        stateDisabledByPolicy.disabledByPolicy = true

        tileView.changeState(stateActive)
        val activeColors = tileView.getCurrentColors()

        tileView.changeState(stateDisabledByPolicy)
        // It has unavailable colors
        assertThat(tileView.getCurrentColors()).isNotEqualTo(activeColors)

        // When we get back to not disabled by policy tile, it should go back to active colors
        tileView.changeState(stateActive)
        assertThat(tileView.getCurrentColors()).containsExactlyElementsIn(activeColors)
    }

    @Test
    fun testDisabledByPolicy_secondaryLabelText() {
        val testA11yLabel = "TEST_LABEL"