Rename context variable and format code

Bug: 372774754
Test: atest
Flag: EXEMPT minor fix
Change-Id: I6cb128afa54613b7c7dba97749f21976ef82a960
This commit is contained in:
Fan Wu
2024-10-18 09:15:49 +00:00
parent f788c33aa4
commit 7ae49a51ea

View File

@@ -38,8 +38,8 @@ class PowerUsageSummaryScreenTest : CatalystScreenTestCase() {
private val mockResources = mock<Resources>() private val mockResources = mock<Resources>()
private val contextWrapper = private val context =
object : ContextWrapper(context) { object : ContextWrapper(appContext) {
override fun getResources(): Resources = mockResources override fun getResources(): Resources = mockResources
} }
@@ -52,26 +52,28 @@ class PowerUsageSummaryScreenTest : CatalystScreenTestCase() {
fun isAvailable_configTrue_shouldReturnTrue() { fun isAvailable_configTrue_shouldReturnTrue() {
mockResources.stub { on { getBoolean(anyInt()) } doReturn true } mockResources.stub { on { getBoolean(anyInt()) } doReturn true }
assertThat(preferenceScreenCreator.isAvailable(contextWrapper)).isTrue() assertThat(preferenceScreenCreator.isAvailable(context)).isTrue()
} }
@Test @Test
fun isAvailable_configFalse_shouldReturnFalse() { fun isAvailable_configFalse_shouldReturnFalse() {
mockResources.stub { on { getBoolean(anyInt()) } doReturn false } mockResources.stub { on { getBoolean(anyInt()) } doReturn false }
assertThat(preferenceScreenCreator.isAvailable(contextWrapper)).isFalse() assertThat(preferenceScreenCreator.isAvailable(context)).isFalse()
} }
@Test @Test
@EnableFlags(Flags.FLAG_HOMEPAGE_REVAMP) @EnableFlags(Flags.FLAG_HOMEPAGE_REVAMP)
fun getIcon_whenHomePageRevampFlagOn() { fun getIcon_whenHomePageRevampFlagOn() {
assertThat(preferenceScreenCreator.getIcon(contextWrapper)).isEqualTo(R.drawable.ic_settings_battery_filled) assertThat(preferenceScreenCreator.getIcon(context))
.isEqualTo(R.drawable.ic_settings_battery_filled)
} }
@Test @Test
@DisableFlags(Flags.FLAG_HOMEPAGE_REVAMP) @DisableFlags(Flags.FLAG_HOMEPAGE_REVAMP)
fun getIcon_whenHomePageRevampFlagOff() { fun getIcon_whenHomePageRevampFlagOff() {
assertThat(preferenceScreenCreator.getIcon(contextWrapper)).isEqualTo(R.drawable.ic_settings_battery_white) assertThat(preferenceScreenCreator.getIcon(context))
.isEqualTo(R.drawable.ic_settings_battery_white)
} }
override fun migration() {} override fun migration() {}