From e08e27a6fab237ec2bc71db67bf35a1c1eed9d1d Mon Sep 17 00:00:00 2001 From: Nick Gerleman Date: Tue, 17 Jun 2025 12:13:27 -0700 Subject: [PATCH] Support Facsimile Views in Jest E2E Text Selectors (#52070) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/52070 Changelog: [Internal] Reviewed By: joevilches, rshest Differential Revision: D76783111 fbshipit-source-id: 5f4c3a9cf6d59eff15a071761ef83425bd4c6d23 --- .../com/facebook/react/views/text/PreparedLayoutTextView.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/PreparedLayoutTextView.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/PreparedLayoutTextView.kt index 7daad76173c..b3c5aeacad4 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/PreparedLayoutTextView.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/PreparedLayoutTextView.kt @@ -23,6 +23,7 @@ import androidx.annotation.ColorInt import androidx.annotation.DoNotInline import androidx.annotation.RequiresApi import androidx.core.view.ViewCompat +import com.facebook.proguard.annotations.DoNotStrip import com.facebook.react.uimanager.BackgroundStyleApplicator import com.facebook.react.uimanager.ReactCompoundView import com.facebook.react.uimanager.style.Overflow @@ -36,6 +37,7 @@ import kotlin.math.roundToInt * existing layout, previously generated for measurement by Fabric, to ensure consistency of * measurements, and avoid duplicate work. */ +@DoNotStrip internal class PreparedLayoutTextView(context: Context) : ViewGroup(context), ReactCompoundView { private var clickableSpans: List = emptyList() @@ -74,7 +76,9 @@ internal class PreparedLayoutTextView(context: Context) : ViewGroup(context), Re @ColorInt var selectionColor: Int? = null val text: CharSequence? - get() = preparedLayout?.layout?.text + // Avoid mangling the getter name, to allow black box E2E tests to read text content via + // reflection + @DoNotStrip get() = preparedLayout?.layout?.text init { initView()