From ca516b2db0d8982fc2ab6da24e9d14342c321750 Mon Sep 17 00:00:00 2001 From: Nick Gerleman Date: Sat, 27 Jul 2024 17:34:12 -0700 Subject: [PATCH] Add Android RTL Coverage to ReactNativeCoreE2E tests Summary: We add a variant where we set RTL locales, and force RTL (because I think `Locale.getDefault()`, in RNTester, never returned desired value even after some build twiddling to include more res). I added a system property apart from the SharedPreferences for `I18nManager` forceRTL to make it easier to prepare test environment. Tests can opt into supporting only a single layout direction, but test against both by default, where we seem to be able to execute the tests successfully right now for the 53 turned on. Changelog: [Internal] Differential Revision: D60345614 --- .../java/com/facebook/react/modules/i18nmanager/I18nUtil.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/i18nmanager/I18nUtil.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/i18nmanager/I18nUtil.kt index 7491cadd45bc..089e7a384f88 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/i18nmanager/I18nUtil.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/i18nmanager/I18nUtil.kt @@ -53,7 +53,8 @@ public class I18nUtil private constructor() { /** Could be used to test RTL layout with English Used for development and testing purpose */ private fun isRTLForced(context: Context): Boolean = - isPrefSet(context, KEY_FOR_PREFS_FORCERTL, false) + isPrefSet(context, KEY_FOR_PREFS_FORCERTL, false) || + System.getProperty("FORCE_RTL_FOR_TESTING", "false").equals("true", ignoreCase = true) public fun forceRTL(context: Context, forceRTL: Boolean) { setPref(context, KEY_FOR_PREFS_FORCERTL, forceRTL)