Skip to content

Commit

Permalink
ANDROID-14391 Fix brands
Browse files Browse the repository at this point in the history
  • Loading branch information
jeprubio committed Apr 4, 2024
1 parent 08dc800 commit 243ec39
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
14 changes: 10 additions & 4 deletions library/src/test/java/com/telefonica/mistica/button/ButtonTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ import com.telefonica.mistica.DummyActivity
import com.telefonica.mistica.DummyActivity.Companion.EXTRA_THEME
import com.telefonica.mistica.R
import com.telefonica.mistica.compose.button.ButtonStyle
import com.telefonica.mistica.compose.theme.brand.BlauBrand
import com.telefonica.mistica.compose.theme.brand.Brand
import com.telefonica.mistica.compose.theme.brand.MovistarBrand
import com.telefonica.mistica.compose.theme.brand.O2Brand
import com.telefonica.mistica.compose.theme.brand.TelefonicaBrand
import com.telefonica.mistica.compose.theme.brand.TuBrand
import com.telefonica.mistica.compose.theme.brand.VivoBrand
import com.telefonica.mistica.compose.theme.brand.VivoNewBrand
import com.telefonica.mistica.testutils.ScreenshotsTest
import com.telefonica.mistica.testutils.TestUtils.getAllBrands
import com.telefonica.mistica.testutils.TestUtils.isInverse
Expand Down Expand Up @@ -83,7 +87,7 @@ internal class ButtonTest(
@ParameterizedRobolectricTestRunner.Parameters(name = "ButtonXML {1} {0} icon={2}")
fun brands(): List<Array<Any>> {
val allBrands = getAllBrands()
val buttonStyles = ButtonStyle.values().toList()
val buttonStyles = ButtonStyle.entries
val icons = listOf(false, true)
return allBrands.flatMap { brand ->
buttonStyles.flatMap { buttonStyle ->
Expand All @@ -99,10 +103,12 @@ internal class ButtonTest(
fun Brand.getBaseThemeForBrand(): Int = when (this) {
MovistarBrand -> R.style.MisticaTheme_Movistar_test
VivoBrand -> R.style.MisticaTheme_Vivo_test
VivoBrand -> R.style.MisticaTheme_O2_test
VivoBrand -> R.style.MisticaTheme_Blau_test
O2Brand -> R.style.MisticaTheme_O2_test
BlauBrand -> R.style.MisticaTheme_Blau_test
TelefonicaBrand -> R.style.MisticaTheme_Telefonica_test
TuBrand -> R.style.MisticaTheme_Tu_test
else -> R.style.MisticaTheme_Telefonica_test
VivoNewBrand -> R.style.MisticaTheme_VivoNew_test
else -> throw IllegalArgumentException("Unexpected brand $this")
}

fun ButtonStyle.getButtonStyleRef() = when (this) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.telefonica.mistica.compose.theme.brand.O2Brand
import com.telefonica.mistica.compose.theme.brand.TelefonicaBrand
import com.telefonica.mistica.compose.theme.brand.TuBrand
import com.telefonica.mistica.compose.theme.brand.VivoBrand
import com.telefonica.mistica.compose.theme.brand.VivoNewBrand
import org.junit.Test

object TestUtils {
Expand Down Expand Up @@ -35,6 +36,7 @@ object TestUtils {
BlauBrand,
TelefonicaBrand,
TuBrand,
VivoNewBrand,
)

fun ButtonStyle.isInverse() = when(this) {
Expand Down

0 comments on commit 243ec39

Please sign in to comment.