Skip to content

Commit

Permalink
GT=2322 Create Preview and snapshot of isForcedName
Browse files Browse the repository at this point in the history
  • Loading branch information
gyasistory committed Jun 20, 2024
1 parent cdbac3a commit 9ab2c04
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import androidx.compose.material3.HorizontalDivider
import androidx.compose.runtime.Composable
import androidx.compose.ui.tooling.preview.Preview
import java.util.Locale
import org.cru.godtools.model.Language

@Composable
@Preview(locale = "en", showBackground = true)
Expand All @@ -14,6 +15,7 @@ private fun LeftToRightLanguageNames() = Column {
LanguageName(Locale.forLanguageTag("bs-BA"))
HorizontalDivider()
LanguageName(Locale.ENGLISH)
LanguageName(language = forcedNameLanguage)
}

@Composable
Expand All @@ -24,4 +26,11 @@ private fun RightToLeftLanguageNames() = Column {
LanguageName(Locale.forLanguageTag("bs-BA"))
HorizontalDivider()
LanguageName(Locale.ENGLISH)
LanguageName(language = forcedNameLanguage)
}

private val forcedNameLanguage = Language(
code = Locale.ENGLISH,
name = "German",
isForcedName = true,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package org.cru.godtools.ui.languages

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.HorizontalDivider
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.android.ide.common.rendering.api.SessionParams.RenderingMode
import com.android.resources.NightMode
import com.google.testing.junit.testparameterinjector.TestParameter
import com.google.testing.junit.testparameterinjector.TestParameterInjector
import java.util.Locale
import org.cru.godtools.model.Language
import org.cru.godtools.ui.BasePaparazziTest
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(TestParameterInjector::class)
class LanguageNamePaparazziTest(@TestParameter nightMode: NightMode) :
BasePaparazziTest(nightMode = nightMode, renderingMode = RenderingMode.SHRINK) {
private val forcedNameLanguage = Language(
code = Locale.ENGLISH,
name = "German",
isForcedName = true,
)

@Test
fun `LanguageNames()`() = centerInSnapshot {
Column(Modifier.padding(16.dp)) {
LanguageName(Locale("ar"))
HorizontalDivider()
LanguageName(Locale.forLanguageTag("bs-BA"))
HorizontalDivider()
LanguageName(Locale.ENGLISH)
HorizontalDivider()
LanguageName(language = forcedNameLanguage)
}
}
}

0 comments on commit 9ab2c04

Please sign in to comment.