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

Commit e05e51d3 authored by Caitlin Shkuratov's avatar Caitlin Shkuratov Committed by Android (Google) Code Review
Browse files

Merge "[SB Refactor] Don't show RAT icon if the resource ID is invalid." into udc-dev

parents 33a3e413 bd2eb04e
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -170,7 +170,10 @@ constructor(
                    if (networkTypeIconGroup.dataContentDescription != 0)
                        ContentDescription.Resource(networkTypeIconGroup.dataContentDescription)
                    else null
                val icon = Icon.Resource(networkTypeIconGroup.dataType, desc)
                val icon =
                    if (networkTypeIconGroup.dataType != 0)
                        Icon.Resource(networkTypeIconGroup.dataType, desc)
                    else null
                return@combine when {
                    !shouldShow -> null
                    else -> icon
+17 −1
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import androidx.test.filters.SmallTest
import com.android.settingslib.AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH
import com.android.settingslib.AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH_NONE
import com.android.settingslib.mobile.TelephonyIcons.THREE_G
import com.android.settingslib.mobile.TelephonyIcons.UNKNOWN
import com.android.systemui.SysuiTestCase
import com.android.systemui.common.shared.model.ContentDescription
import com.android.systemui.common.shared.model.Icon
@@ -343,7 +344,7 @@ class MobileIconViewModelTest : SysuiTestCase() {
    fun networkType_alwaysShow_shownEvenWhenDisabled() =
        testScope.runTest {
            interactor.setIconGroup(THREE_G)
            interactor.setIsDataEnabled(true)
            interactor.setIsDataEnabled(false)
            interactor.alwaysShowDataRatIcon.value = true

            var latest: Icon? = null
@@ -399,6 +400,21 @@ class MobileIconViewModelTest : SysuiTestCase() {
            job.cancel()
        }

    @Test
    fun networkType_alwaysShow_notShownWhenInvalidDataTypeIcon() =
        testScope.runTest {
            // The UNKNOWN icon group doesn't have a valid data type icon ID
            interactor.setIconGroup(UNKNOWN)
            interactor.alwaysShowDataRatIcon.value = true

            var latest: Icon? = null
            val job = underTest.networkTypeIcon.onEach { latest = it }.launchIn(this)

            assertThat(latest).isNull()

            job.cancel()
        }

    @Test
    fun `network type - alwaysShow - shown when not default`() =
        testScope.runTest {