mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-03 16:10:00 +00:00
Force the default locale to the selected one for screenshot tests (#805)
This commit is contained in:
committed by
GitHub
parent
f7dd327cb6
commit
ea381cda2c
@@ -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()
|
||||||
|
|||||||
Reference in New Issue
Block a user