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

Commit 44784ed5 authored by Olivier St-Onge's avatar Olivier St-Onge Committed by Android (Google) Code Review
Browse files

Merge "Reset fake mobile connection repos between tests" into main

parents 10555fef 2a1a53b2
Loading
Loading
Loading
Loading
+24 −20
Original line number Diff line number Diff line
@@ -65,10 +65,10 @@ class MobileIconsInteractorTest : SysuiTestCase() {
            mobileConnectionsRepository.fake.run {
                setMobileConnectionRepositoryMap(
                    mapOf(
                        SUB_1_ID to CONNECTION_1,
                        SUB_2_ID to CONNECTION_2,
                        SUB_3_ID to CONNECTION_3,
                        SUB_4_ID to CONNECTION_4,
                        SUB_1_ID to FakeMobileConnectionRepository(SUB_1_ID, mock()),
                        SUB_2_ID to FakeMobileConnectionRepository(SUB_2_ID, mock()),
                        SUB_3_ID to FakeMobileConnectionRepository(SUB_3_ID, mock()),
                        SUB_4_ID to FakeMobileConnectionRepository(SUB_4_ID, mock()),
                    )
                )
                setActiveMobileDataSubscriptionId(SUB_1_ID)
@@ -496,7 +496,10 @@ class MobileIconsInteractorTest : SysuiTestCase() {
    @Test
    fun activeDataConnection_turnedOn() =
        kosmos.runTest {
            CONNECTION_1.setDataEnabled(true)
            (fakeMobileConnectionsRepository.getRepoForSubId(SUB_1_ID)
                    as FakeMobileConnectionRepository)
                .dataEnabled
                .value = true

            val latest by collectLastValue(underTest.activeDataConnectionHasDataEnabled)

@@ -506,10 +509,17 @@ class MobileIconsInteractorTest : SysuiTestCase() {
    @Test
    fun activeDataConnection_turnedOff() =
        kosmos.runTest {
            CONNECTION_1.setDataEnabled(true)
            (fakeMobileConnectionsRepository.getRepoForSubId(SUB_1_ID)
                    as FakeMobileConnectionRepository)
                .dataEnabled
                .value = true

            val latest by collectLastValue(underTest.activeDataConnectionHasDataEnabled)

            CONNECTION_1.setDataEnabled(false)
            (fakeMobileConnectionsRepository.getRepoForSubId(SUB_1_ID)
                    as FakeMobileConnectionRepository)
                .dataEnabled
                .value = false

            assertThat(latest).isFalse()
        }
@@ -921,20 +931,18 @@ class MobileIconsInteractorTest : SysuiTestCase() {
    @EnableFlags(NewStatusBarIcons.FLAG_NAME, StatusBarRootModernization.FLAG_NAME)
    fun isStackable_checksForTerrestrialConnections() =
        kosmos.runTest {
            val exclusivelyNonTerrestrialSub =
                SubscriptionModel(
                    isExclusivelyNonTerrestrial = true,
                    subscriptionId = 5,
                    carrierName = "Carrier 5",
                    profileClass = PROFILE_CLASS_UNSET,
                )

            val latest by collectLastValue(underTest.isStackable)

            connectionsRepository.setSubscriptions(listOf(SUB_1, SUB_2))
            setNumberOfLevelsForSubId(SUB_1_ID, 5)
            setNumberOfLevelsForSubId(SUB_2_ID, 5)
            assertThat(latest).isTrue()

            connectionsRepository.setSubscriptions(listOf(SUB_1, exclusivelyNonTerrestrialSub))
            (fakeMobileConnectionsRepository.getRepoForSubId(SUB_1_ID)
                    as FakeMobileConnectionRepository)
                .isNonTerrestrial
                .value = true

            assertThat(latest).isFalse()
        }

@@ -1006,7 +1014,6 @@ class MobileIconsInteractorTest : SysuiTestCase() {
                carrierName = "Carrier $SUB_1_ID",
                profileClass = PROFILE_CLASS_UNSET,
            )
        private val CONNECTION_1 = FakeMobileConnectionRepository(SUB_1_ID, mock())

        private const val SUB_2_ID = 2
        private val SUB_2 =
@@ -1015,7 +1022,6 @@ class MobileIconsInteractorTest : SysuiTestCase() {
                carrierName = "Carrier $SUB_2_ID",
                profileClass = PROFILE_CLASS_UNSET,
            )
        private val CONNECTION_2 = FakeMobileConnectionRepository(SUB_2_ID, mock())

        private const val SUB_3_ID = 3
        private val SUB_3_OPP =
@@ -1026,7 +1032,6 @@ class MobileIconsInteractorTest : SysuiTestCase() {
                carrierName = "Carrier $SUB_3_ID",
                profileClass = PROFILE_CLASS_UNSET,
            )
        private val CONNECTION_3 = FakeMobileConnectionRepository(SUB_3_ID, mock())

        private const val SUB_4_ID = 4
        private val SUB_4_OPP =
@@ -1037,6 +1042,5 @@ class MobileIconsInteractorTest : SysuiTestCase() {
                carrierName = "Carrier $SUB_4_ID",
                profileClass = PROFILE_CLASS_UNSET,
            )
        private val CONNECTION_4 = FakeMobileConnectionRepository(SUB_4_ID, mock())
    }
}