Skip to content

Commit

Permalink
GT-2322 Create Preview and snapshot of isForcedName
Browse files Browse the repository at this point in the history
Co-Authored-By: Daniel Frett <[email protected]>
  • Loading branch information
gyasistory and frett committed Jun 20, 2024
1 parent c54a81e commit a5abd61
Show file tree
Hide file tree
Showing 4 changed files with 56 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,8 @@ private fun LeftToRightLanguageNames() = Column {
LanguageName(Locale.forLanguageTag("bs-BA"))
HorizontalDivider()
LanguageName(Locale.ENGLISH)
HorizontalDivider()
LanguageName(language = forcedNameLanguage)
}

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

private val forcedNameLanguage = Language(
code = Locale.ENGLISH,
name = "German",
isForcedName = true,
)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 = "Forced Language Name",
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 a5abd61

Please sign in to comment.