Force the default locale to the selected one for screenshot tests (#805)
This commit is contained in:
parent
b43bd37419
commit
f98427a41a
1 changed files with 4 additions and 2 deletions
|
|
@ -81,6 +81,8 @@ class ScreenshotTest {
|
||||||
@TestParameter(value = ["1.0"/*, "1.5"*/]) fontScale: Float,
|
@TestParameter(value = ["1.0"/*, "1.5"*/]) fontScale: Float,
|
||||||
@TestParameter(value = ["en" /*"fr", "de", "ru"*/]) localeStr: String,
|
@TestParameter(value = ["en" /*"fr", "de", "ru"*/]) localeStr: String,
|
||||||
) {
|
) {
|
||||||
|
val locale = localeStr.toLocale()
|
||||||
|
Locale.setDefault(locale) // Needed for regional settings, as first day of week
|
||||||
paparazzi.unsafeUpdateConfig(
|
paparazzi.unsafeUpdateConfig(
|
||||||
deviceConfig = baseDeviceConfig.deviceConfig.copy(
|
deviceConfig = baseDeviceConfig.deviceConfig.copy(
|
||||||
softButtons = false
|
softButtons = false
|
||||||
|
|
@ -95,7 +97,7 @@ class ScreenshotTest {
|
||||||
fontScale = fontScale
|
fontScale = fontScale
|
||||||
),
|
),
|
||||||
LocalConfiguration provides Configuration().apply {
|
LocalConfiguration provides Configuration().apply {
|
||||||
setLocales(LocaleList(localeStr.toLocale()))
|
setLocales(LocaleList(locale))
|
||||||
// Dark mode previews have name "N" so their component name contains "- N"
|
// Dark mode previews have name "N" so their component name contains "- N"
|
||||||
if (componentTestPreview.name.contains("- $NIGHT_MODE_NAME")){
|
if (componentTestPreview.name.contains("- $NIGHT_MODE_NAME")){
|
||||||
uiMode = Configuration.UI_MODE_NIGHT_YES
|
uiMode = Configuration.UI_MODE_NIGHT_YES
|
||||||
|
|
@ -122,7 +124,7 @@ class ScreenshotTest {
|
||||||
|
|
||||||
private fun String.toLocale(): Locale {
|
private fun String.toLocale(): Locale {
|
||||||
return when (this) {
|
return when (this) {
|
||||||
"en" -> Locale.ENGLISH
|
"en" -> Locale.US
|
||||||
"fr" -> Locale.FRANCE
|
"fr" -> Locale.FRANCE
|
||||||
"de" -> Locale.GERMAN
|
"de" -> Locale.GERMAN
|
||||||
else -> Locale.Builder().setLanguage(this).build()
|
else -> Locale.Builder().setLanguage(this).build()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue