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

Commit ac950242 authored by Behnam Heydarshahi's avatar Behnam Heydarshahi Committed by Android (Google) Code Review
Browse files

Merge "Load tile icons while mapping state" into main

parents 3e5fe428 8b7b9fb2
Loading
Loading
Loading
Loading
+4 −8
Original line number Diff line number Diff line
@@ -115,7 +115,7 @@ class QSTileLoggerTest : SysuiTestCase() {
        underTest.logUserActionPipeline(
            TileSpec.create("test_spec"),
            QSTileUserAction.Click(null),
            QSTileState.build({ Icon.Resource(0, ContentDescription.Resource(0)) }, "") {},
            QSTileState.build(Icon.Resource(0, ContentDescription.Resource(0)), "") {},
            "test_data",
        )

@@ -141,7 +141,7 @@ class QSTileLoggerTest : SysuiTestCase() {
    fun testLogStateUpdate() {
        underTest.logStateUpdate(
            TileSpec.create("test_spec"),
            QSTileState.build({ Icon.Resource(0, ContentDescription.Resource(0)) }, "") {},
            QSTileState.build(Icon.Resource(0, ContentDescription.Resource(0)), "") {},
            "test_data",
        )

@@ -162,18 +162,14 @@ class QSTileLoggerTest : SysuiTestCase() {

    @Test
    fun testLogForceUpdate() {
        underTest.logForceUpdate(
            TileSpec.create("test_spec"),
        )
        underTest.logForceUpdate(TileSpec.create("test_spec"))

        assertThat(logBuffer.getStringBuffer()).contains("tile data force update")
    }

    @Test
    fun testLogInitialUpdate() {
        underTest.logInitialRequest(
            TileSpec.create("test_spec"),
        )
        underTest.logInitialRequest(TileSpec.create("test_spec"))

        assertThat(logBuffer.getStringBuffer()).contains("tile data initial update")
    }
+3 −3
Original line number Diff line number Diff line
@@ -85,8 +85,8 @@ class QSTileViewModelImplTest : SysuiTestCase() {
                    object : QSTileDataToStateMapper<Any> {
                        override fun map(config: QSTileConfig, data: Any): QSTileState =
                            QSTileState.build(
                                { Icon.Resource(0, ContentDescription.Resource(0)) },
                                data.toString()
                                Icon.Resource(0, ContentDescription.Resource(0)),
                                data.toString(),
                            ) {}
                    }
                },
@@ -116,7 +116,7 @@ class QSTileViewModelImplTest : SysuiTestCase() {
                .isEqualTo(
                    "test_spec:\n" +
                        "    QSTileState(" +
                        "icon=() -> com.android.systemui.common.shared.model.Icon?, " +
                        "icon=Resource(res=0, contentDescription=Resource(res=0)), " +
                        "iconRes=null, " +
                        "label=test_data, " +
                        "activationState=INACTIVE, " +
+5 −5
Original line number Diff line number Diff line
@@ -66,7 +66,7 @@ class AirplaneModeMapperTest : SysuiTestCase() {
            createAirplaneModeState(
                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)
    }
@@ -81,7 +81,7 @@ class AirplaneModeMapperTest : SysuiTestCase() {
            createAirplaneModeState(
                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)
    }
@@ -89,11 +89,11 @@ class AirplaneModeMapperTest : SysuiTestCase() {
    private fun createAirplaneModeState(
        activationState: QSTileState.ActivationState,
        secondaryLabel: String,
        iconRes: Int
        iconRes: Int,
    ): QSTileState {
        val label = context.getString(R.string.airplane_mode)
        return QSTileState(
            { Icon.Loaded(context.getDrawable(iconRes)!!, null) },
            Icon.Loaded(context.getDrawable(iconRes)!!, null),
            iconRes,
            label,
            activationState,
@@ -103,7 +103,7 @@ class AirplaneModeMapperTest : SysuiTestCase() {
            null,
            QSTileState.SideViewIcon.None,
            QSTileState.EnabledState.ENABLED,
            Switch::class.qualifiedName
            Switch::class.qualifiedName,
        )
    }
}
+10 −10
Original line number Diff line number Diff line
@@ -51,7 +51,7 @@ class AlarmTileMapperTest : SysuiTestCase() {
                .apply { addOverride(R.drawable.ic_alarm, TestStubDrawable()) }
                .resources,
            context.theme,
            fakeClock
            fakeClock,
        )
    }

@@ -69,7 +69,7 @@ class AlarmTileMapperTest : SysuiTestCase() {
        val expectedState =
            createAlarmTileState(
                QSTileState.ActivationState.INACTIVE,
                context.getString(R.string.qs_alarm_tile_no_alarm)
                context.getString(R.string.qs_alarm_tile_no_alarm),
            )
        QSTileStateSubject.assertThat(outputState).isEqualTo(expectedState)
    }
@@ -85,7 +85,7 @@ class AlarmTileMapperTest : SysuiTestCase() {
        val localDateTime =
            LocalDateTime.ofInstant(
                Instant.ofEpochMilli(triggerTime),
                TimeZone.getDefault().toZoneId()
                TimeZone.getDefault().toZoneId(),
            )
        val expectedSecondaryLabel = AlarmTileMapper.formatter24Hour.format(localDateTime)
        val expectedState =
@@ -104,7 +104,7 @@ class AlarmTileMapperTest : SysuiTestCase() {
        val localDateTime =
            LocalDateTime.ofInstant(
                Instant.ofEpochMilli(triggerTime),
                TimeZone.getDefault().toZoneId()
                TimeZone.getDefault().toZoneId(),
            )
        val expectedSecondaryLabel = AlarmTileMapper.formatter12Hour.format(localDateTime)
        val expectedState =
@@ -124,7 +124,7 @@ class AlarmTileMapperTest : SysuiTestCase() {
        val localDateTime =
            LocalDateTime.ofInstant(
                Instant.ofEpochMilli(triggerTime),
                TimeZone.getDefault().toZoneId()
                TimeZone.getDefault().toZoneId(),
            )
        val expectedSecondaryLabel = AlarmTileMapper.formatterDateOnly.format(localDateTime)
        val expectedState =
@@ -144,7 +144,7 @@ class AlarmTileMapperTest : SysuiTestCase() {
        val localDateTime =
            LocalDateTime.ofInstant(
                Instant.ofEpochMilli(triggerTime),
                TimeZone.getDefault().toZoneId()
                TimeZone.getDefault().toZoneId(),
            )
        val expectedSecondaryLabel = AlarmTileMapper.formatter12Hour.format(localDateTime)
        val expectedState =
@@ -164,7 +164,7 @@ class AlarmTileMapperTest : SysuiTestCase() {
        val localDateTime =
            LocalDateTime.ofInstant(
                Instant.ofEpochMilli(triggerTime),
                TimeZone.getDefault().toZoneId()
                TimeZone.getDefault().toZoneId(),
            )
        val expectedSecondaryLabel = AlarmTileMapper.formatterDateOnly.format(localDateTime)
        val expectedState =
@@ -174,11 +174,11 @@ class AlarmTileMapperTest : SysuiTestCase() {

    private fun createAlarmTileState(
        activationState: QSTileState.ActivationState,
        secondaryLabel: String
        secondaryLabel: String,
    ): QSTileState {
        val label = context.getString(R.string.status_bar_alarm)
        return QSTileState(
            { Icon.Loaded(context.getDrawable(R.drawable.ic_alarm)!!, null) },
            Icon.Loaded(context.getDrawable(R.drawable.ic_alarm)!!, null),
            R.drawable.ic_alarm,
            label,
            activationState,
@@ -188,7 +188,7 @@ class AlarmTileMapperTest : SysuiTestCase() {
            null,
            QSTileState.SideViewIcon.Chevron,
            QSTileState.EnabledState.ENABLED,
            Switch::class.qualifiedName
            Switch::class.qualifiedName,
        )
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -253,7 +253,7 @@ class BatterySaverTileMapperTest : SysuiTestCase() {
    ): QSTileState {
        val label = context.getString(R.string.battery_detail_switch_title)
        return QSTileState(
            { Icon.Loaded(context.getDrawable(iconRes)!!, null) },
            Icon.Loaded(context.getDrawable(iconRes)!!, null),
            iconRes,
            label,
            activationState,
@@ -265,7 +265,7 @@ class BatterySaverTileMapperTest : SysuiTestCase() {
            stateDescription,
            QSTileState.SideViewIcon.None,
            QSTileState.EnabledState.ENABLED,
            Switch::class.qualifiedName
            Switch::class.qualifiedName,
        )
    }
}
Loading