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

Commit 4466b845 authored by Andrew Xu's avatar Andrew Xu Committed by Android (Google) Code Review
Browse files

Merge "Avoid reusing the same battery view model instance in Kosmos" into main

parents 8d61d355 ebf03681
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
class BatteryViewModelAlwaysShowPercentTest : SysuiTestCase() {
    val kosmos = testKosmos()
    val Kosmos.underTest by Kosmos.Fixture { batteryViewModelAlwaysShowPercent }
    val Kosmos.underTest by Kosmos.Fixture { batteryViewModelAlwaysShowPercentFactory.create() }

    @Before
    fun setUp() {
+1 −1
Original line number Diff line number Diff line
@@ -41,7 +41,7 @@ import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
class BatteryViewModelBasedOnSettingTest : SysuiTestCase() {
    val kosmos = testKosmos()
    val Kosmos.underTest by Kosmos.Fixture { batteryViewModelBasedOnSetting }
    val Kosmos.underTest by Kosmos.Fixture { batteryViewModelBasedOnSettingFactory.create() }

    @Before
    fun setUp() {
+3 −1
Original line number Diff line number Diff line
@@ -39,7 +39,9 @@ import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
class BatteryViewModelShowWhenChargingTest : SysuiTestCase() {
    val kosmos = testKosmos()
    val Kosmos.underTest by Kosmos.Fixture { batteryViewModelShowWhenChargingOrSetting }
    val Kosmos.underTest by Kosmos.Fixture {
        batteryViewModelShowWhenChargingOrSettingFactory.create()
    }

    @Before
    fun setUp() {
+15 −18
Original line number Diff line number Diff line
@@ -20,40 +20,37 @@ import android.content.testableContext
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.statusbar.pipeline.battery.domain.interactor.batteryInteractor

val Kosmos.batteryViewModelBasedOnSetting by
    Kosmos.Fixture { BatteryViewModel.BasedOnUserSetting(batteryInteractor, testableContext) }

val Kosmos.batteryViewModelBasedOnSettingFactory by
    Kosmos.Fixture {
        BatteryViewModel.BasedOnUserSetting.Factory { batteryViewModelBasedOnSetting }
        BatteryViewModel.BasedOnUserSetting.Factory {
            BatteryViewModel.BasedOnUserSetting(
                batteryInteractor,
                testableContext
            )
        }

val Kosmos.batteryViewModelShowWhenChargingOrSetting by
    Kosmos.Fixture {
        BatteryViewModel.ShowPercentWhenChargingOrSetting(batteryInteractor, testableContext)
    }

val Kosmos.batteryViewModelShowWhenChargingOrSettingFactory by
    Kosmos.Fixture {
        BatteryViewModel.ShowPercentWhenChargingOrSetting.Factory {
            batteryViewModelShowWhenChargingOrSetting
            BatteryViewModel.ShowPercentWhenChargingOrSetting(batteryInteractor, testableContext)
        }
    }

val Kosmos.batteryViewModelAlwaysShowPercent by
    Kosmos.Fixture { BatteryViewModel.AlwaysShowPercent(batteryInteractor, testableContext) }

val Kosmos.batteryViewModelAlwaysShowPercentFactory by
    Kosmos.Fixture {
        BatteryViewModel.AlwaysShowPercent.Factory { batteryViewModelAlwaysShowPercent }
        BatteryViewModel.AlwaysShowPercent.Factory {
            BatteryViewModel.AlwaysShowPercent(
                batteryInteractor,
                testableContext
            )
        }
    }

val Kosmos.batteryWithPercentViewModel by
    Kosmos.Fixture { BatteryNextToPercentViewModel(batteryInteractor, testableContext) }

val Kosmos.batteryWithPercentViewModelFactory by
    Kosmos.Fixture {
        object : BatteryNextToPercentViewModel.Factory {
            override fun create(): BatteryNextToPercentViewModel = batteryWithPercentViewModel
            override fun create(): BatteryNextToPercentViewModel =
                BatteryNextToPercentViewModel(batteryInteractor, testableContext)
        }
    }