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

Commit 51f68d9a authored by Fabian Kozynski's avatar Fabian Kozynski Committed by Android (Google) Code Review
Browse files

Merge "Remove auto On/Off for tiles" into main

parents 04c59c79 54b15763
Loading
Loading
Loading
Loading
+8 −4
Original line number Original line Diff line number Diff line
@@ -168,7 +168,7 @@ class TileUiStateTest : SysuiTestCase() {
    }
    }


    @Test
    @Test
    fun switchInactive_emptySecondaryLabel_defaultOff() {
    fun switchInactive_emptySecondaryLabel_defaultOff_onlyOnStateDescription() {
        val state =
        val state =
            QSTile.State().apply {
            QSTile.State().apply {
                expandedAccessibilityClassName = Switch::class.java.name
                expandedAccessibilityClassName = Switch::class.java.name
@@ -178,11 +178,13 @@ class TileUiStateTest : SysuiTestCase() {


        val uiState = state.toUiState()
        val uiState = state.toUiState()


        assertThat(uiState.secondaryLabel).isEqualTo(resources.getString(R.string.switch_bar_off))
        assertThat(uiState.secondaryLabel).isEmpty()
        assertThat(uiState.accessibilityUiState.stateDescription)
            .isEqualTo(resources.getString(R.string.switch_bar_off))
    }
    }


    @Test
    @Test
    fun switchActive_emptySecondaryLabel_defaultOn() {
    fun switchActive_emptySecondaryLabel_defaultOn_onlyOnStateDescription() {
        val state =
        val state =
            QSTile.State().apply {
            QSTile.State().apply {
                expandedAccessibilityClassName = Switch::class.java.name
                expandedAccessibilityClassName = Switch::class.java.name
@@ -192,7 +194,9 @@ class TileUiStateTest : SysuiTestCase() {


        val uiState = state.toUiState()
        val uiState = state.toUiState()


        assertThat(uiState.secondaryLabel).isEqualTo(resources.getString(R.string.switch_bar_on))
        assertThat(uiState.secondaryLabel).isEmpty()
        assertThat(uiState.accessibilityUiState.stateDescription)
            .isEqualTo(resources.getString(R.string.switch_bar_on))
    }
    }


    @Test
    @Test
+2 −6
Original line number Original line Diff line number Diff line
@@ -17,7 +17,6 @@
package com.android.systemui.qs.tiles.impl.airplane.ui.mapper
package com.android.systemui.qs.tiles.impl.airplane.ui.mapper


import android.graphics.drawable.TestStubDrawable
import android.graphics.drawable.TestStubDrawable
import android.service.quicksettings.Tile
import android.widget.Switch
import android.widget.Switch
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import androidx.test.filters.SmallTest
@@ -64,7 +63,6 @@ class AirplaneModeTileMapperTest : SysuiTestCase() {
        val expectedState =
        val expectedState =
            createAirplaneModeState(
            createAirplaneModeState(
                QSTileState.ActivationState.ACTIVE,
                QSTileState.ActivationState.ACTIVE,
                context.resources.getStringArray(R.array.tile_states_airplane)[Tile.STATE_ACTIVE],
                R.drawable.qs_airplane_icon_on,
                R.drawable.qs_airplane_icon_on,
            )
            )
        QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState)
        QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState)
@@ -79,7 +77,6 @@ class AirplaneModeTileMapperTest : SysuiTestCase() {
        val expectedState =
        val expectedState =
            createAirplaneModeState(
            createAirplaneModeState(
                QSTileState.ActivationState.INACTIVE,
                QSTileState.ActivationState.INACTIVE,
                context.resources.getStringArray(R.array.tile_states_airplane)[Tile.STATE_INACTIVE],
                R.drawable.qs_airplane_icon_off,
                R.drawable.qs_airplane_icon_off,
            )
            )
        QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState)
        QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState)
@@ -87,7 +84,6 @@ class AirplaneModeTileMapperTest : SysuiTestCase() {


    private fun createAirplaneModeState(
    private fun createAirplaneModeState(
        activationState: QSTileState.ActivationState,
        activationState: QSTileState.ActivationState,
        secondaryLabel: String,
        iconRes: Int,
        iconRes: Int,
    ): QSTileState {
    ): QSTileState {
        val label = context.getString(R.string.airplane_mode)
        val label = context.getString(R.string.airplane_mode)
@@ -95,10 +91,10 @@ class AirplaneModeTileMapperTest : SysuiTestCase() {
            Icon.Loaded(context.getDrawable(iconRes)!!, null, iconRes),
            Icon.Loaded(context.getDrawable(iconRes)!!, null, iconRes),
            label,
            label,
            activationState,
            activationState,
            secondaryLabel,
            secondaryLabel = null,
            setOf(QSTileState.UserAction.CLICK, QSTileState.UserAction.LONG_CLICK),
            setOf(QSTileState.UserAction.CLICK, QSTileState.UserAction.LONG_CLICK),
            label,
            label,
            null,
            stateDescription = null,
            QSTileState.SideViewIcon.None,
            QSTileState.SideViewIcon.None,
            QSTileState.EnabledState.ENABLED,
            QSTileState.EnabledState.ENABLED,
            Switch::class.qualifiedName,
            Switch::class.qualifiedName,
+6 −11
Original line number Original line Diff line number Diff line
@@ -36,9 +36,7 @@ import org.junit.runner.RunWith
class ColorCorrectionTileMapperTest : SysuiTestCase() {
class ColorCorrectionTileMapperTest : SysuiTestCase() {
    private val kosmos = testKosmos()
    private val kosmos = testKosmos()
    private val colorCorrectionTileConfig = kosmos.qsColorCorrectionTileConfig
    private val colorCorrectionTileConfig = kosmos.qsColorCorrectionTileConfig
    private val subtitleArray by lazy {

        context.resources.getStringArray(R.array.tile_states_color_correction)
    }
    // Using lazy (versus =) to make sure we override the right context -- see b/311612168
    // Using lazy (versus =) to make sure we override the right context -- see b/311612168
    private val mapper by lazy {
    private val mapper by lazy {
        ColorCorrectionTileMapper(
        ColorCorrectionTileMapper(
@@ -55,8 +53,7 @@ class ColorCorrectionTileMapperTest : SysuiTestCase() {


        val outputState = mapper.map(colorCorrectionTileConfig, inputModel)
        val outputState = mapper.map(colorCorrectionTileConfig, inputModel)


        val expectedState =
        val expectedState = createColorCorrectionTileState(QSTileState.ActivationState.INACTIVE)
            createColorCorrectionTileState(QSTileState.ActivationState.INACTIVE, subtitleArray[1])
        QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState)
        QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState)
    }
    }


@@ -66,14 +63,12 @@ class ColorCorrectionTileMapperTest : SysuiTestCase() {


        val outputState = mapper.map(colorCorrectionTileConfig, inputModel)
        val outputState = mapper.map(colorCorrectionTileConfig, inputModel)


        val expectedState =
        val expectedState = createColorCorrectionTileState(QSTileState.ActivationState.ACTIVE)
            createColorCorrectionTileState(QSTileState.ActivationState.ACTIVE, subtitleArray[2])
        QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState)
        QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState)
    }
    }


    private fun createColorCorrectionTileState(
    private fun createColorCorrectionTileState(
        activationState: QSTileState.ActivationState,
        activationState: QSTileState.ActivationState
        secondaryLabel: String,
    ): QSTileState {
    ): QSTileState {
        val label = context.getString(R.string.quick_settings_color_correction_label)
        val label = context.getString(R.string.quick_settings_color_correction_label)
        return QSTileState(
        return QSTileState(
@@ -84,10 +79,10 @@ class ColorCorrectionTileMapperTest : SysuiTestCase() {
            ),
            ),
            label,
            label,
            activationState,
            activationState,
            secondaryLabel,
            secondaryLabel = null,
            setOf(QSTileState.UserAction.CLICK, QSTileState.UserAction.LONG_CLICK),
            setOf(QSTileState.UserAction.CLICK, QSTileState.UserAction.LONG_CLICK),
            label,
            label,
            null,
            stateDescription = null,
            QSTileState.SideViewIcon.None,
            QSTileState.SideViewIcon.None,
            QSTileState.EnabledState.ENABLED,
            QSTileState.EnabledState.ENABLED,
            Switch::class.qualifiedName,
            Switch::class.qualifiedName,
+3 −9
Original line number Original line Diff line number Diff line
@@ -22,7 +22,6 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.SysuiTestCase
import com.android.systemui.common.shared.model.Icon
import com.android.systemui.common.shared.model.Icon
import com.android.systemui.qs.tileimpl.SubtitleArrayMapping
import com.android.systemui.qs.tiles.base.shared.model.QSTileState
import com.android.systemui.qs.tiles.base.shared.model.QSTileState
import com.android.systemui.qs.tiles.base.ui.model.QSTileStateSubject
import com.android.systemui.qs.tiles.base.ui.model.QSTileStateSubject
import com.android.systemui.qs.tiles.impl.inversion.domain.model.ColorInversionTileModel
import com.android.systemui.qs.tiles.impl.inversion.domain.model.ColorInversionTileModel
@@ -37,9 +36,7 @@ import org.junit.runner.RunWith
class ColorInversionTileMapperTest : SysuiTestCase() {
class ColorInversionTileMapperTest : SysuiTestCase() {
    private val kosmos = testKosmos()
    private val kosmos = testKosmos()
    private val colorInversionTileConfig = kosmos.qsColorInversionTileConfig
    private val colorInversionTileConfig = kosmos.qsColorInversionTileConfig
    private val subtitleArrayId =

        SubtitleArrayMapping.getSubtitleId(colorInversionTileConfig.tileSpec.spec)
    private val subtitleArray by lazy { context.resources.getStringArray(subtitleArrayId) }
    // Using lazy (versus =) to make sure we override the right context -- see b/311612168
    // Using lazy (versus =) to make sure we override the right context -- see b/311612168
    private val mapper by lazy {
    private val mapper by lazy {
        ColorInversionTileMapper(
        ColorInversionTileMapper(
@@ -62,7 +59,6 @@ class ColorInversionTileMapperTest : SysuiTestCase() {
        val expectedState =
        val expectedState =
            createColorInversionTileState(
            createColorInversionTileState(
                QSTileState.ActivationState.INACTIVE,
                QSTileState.ActivationState.INACTIVE,
                subtitleArray[1],
                R.drawable.qs_invert_colors_icon_off,
                R.drawable.qs_invert_colors_icon_off,
            )
            )
        QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState)
        QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState)
@@ -77,7 +73,6 @@ class ColorInversionTileMapperTest : SysuiTestCase() {
        val expectedState =
        val expectedState =
            createColorInversionTileState(
            createColorInversionTileState(
                QSTileState.ActivationState.ACTIVE,
                QSTileState.ActivationState.ACTIVE,
                subtitleArray[2],
                R.drawable.qs_invert_colors_icon_on,
                R.drawable.qs_invert_colors_icon_on,
            )
            )
        QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState)
        QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState)
@@ -85,7 +80,6 @@ class ColorInversionTileMapperTest : SysuiTestCase() {


    private fun createColorInversionTileState(
    private fun createColorInversionTileState(
        activationState: QSTileState.ActivationState,
        activationState: QSTileState.ActivationState,
        secondaryLabel: String,
        iconRes: Int,
        iconRes: Int,
    ): QSTileState {
    ): QSTileState {
        val label = context.getString(R.string.quick_settings_inversion_label)
        val label = context.getString(R.string.quick_settings_inversion_label)
@@ -93,10 +87,10 @@ class ColorInversionTileMapperTest : SysuiTestCase() {
            Icon.Loaded(context.getDrawable(iconRes)!!, null, iconRes),
            Icon.Loaded(context.getDrawable(iconRes)!!, null, iconRes),
            label,
            label,
            activationState,
            activationState,
            secondaryLabel,
            secondaryLabel = null,
            setOf(QSTileState.UserAction.CLICK, QSTileState.UserAction.LONG_CLICK),
            setOf(QSTileState.UserAction.CLICK, QSTileState.UserAction.LONG_CLICK),
            label,
            label,
            null,
            stateDescription = null,
            QSTileState.SideViewIcon.None,
            QSTileState.SideViewIcon.None,
            QSTileState.EnabledState.ENABLED,
            QSTileState.EnabledState.ENABLED,
            Switch::class.qualifiedName,
            Switch::class.qualifiedName,
+4 −21
Original line number Original line Diff line number Diff line
@@ -17,7 +17,6 @@
package com.android.systemui.qs.tiles.impl.night.ui.mapper
package com.android.systemui.qs.tiles.impl.night.ui.mapper


import android.graphics.drawable.TestStubDrawable
import android.graphics.drawable.TestStubDrawable
import android.service.quicksettings.Tile
import android.text.TextUtils
import android.text.TextUtils
import android.widget.Switch
import android.widget.Switch
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.ext.junit.runners.AndroidJUnit4
@@ -70,11 +69,7 @@ class NightDisplayTileMapperTest : SysuiTestCase() {


        val outputState = mapper.map(config, inputModel)
        val outputState = mapper.map(config, inputModel)


        val expectedState =
        val expectedState = createNightDisplayTileState(QSTileState.ActivationState.INACTIVE, null)
            createNightDisplayTileState(
                QSTileState.ActivationState.INACTIVE,
                context.resources.getStringArray(R.array.tile_states_night)[Tile.STATE_INACTIVE],
            )
        QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState)
        QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState)
    }
    }


@@ -85,11 +80,7 @@ class NightDisplayTileMapperTest : SysuiTestCase() {


        val outputState = mapper.map(config, inputModel)
        val outputState = mapper.map(config, inputModel)


        val expectedState =
        val expectedState = createNightDisplayTileState(QSTileState.ActivationState.INACTIVE, null)
            createNightDisplayTileState(
                QSTileState.ActivationState.INACTIVE,
                context.resources.getStringArray(R.array.tile_states_night)[Tile.STATE_INACTIVE],
            )
        QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState)
        QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState)
    }
    }


@@ -99,11 +90,7 @@ class NightDisplayTileMapperTest : SysuiTestCase() {


        val outputState = mapper.map(config, inputModel)
        val outputState = mapper.map(config, inputModel)


        val expectedState =
        val expectedState = createNightDisplayTileState(QSTileState.ActivationState.ACTIVE, null)
            createNightDisplayTileState(
                QSTileState.ActivationState.ACTIVE,
                context.resources.getStringArray(R.array.tile_states_night)[Tile.STATE_ACTIVE],
            )
        QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState)
        QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState)
    }
    }


@@ -113,11 +100,7 @@ class NightDisplayTileMapperTest : SysuiTestCase() {


        val outputState = mapper.map(config, inputModel)
        val outputState = mapper.map(config, inputModel)


        val expectedState =
        val expectedState = createNightDisplayTileState(QSTileState.ActivationState.ACTIVE, null)
            createNightDisplayTileState(
                QSTileState.ActivationState.ACTIVE,
                context.resources.getStringArray(R.array.tile_states_night)[Tile.STATE_ACTIVE],
            )
        QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState)
        QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState)
    }
    }


Loading