mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fix ReactImagePropertyTest (#44028)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/44028 Changelog: [Internal] While testing something completely unrelated (i.e. D55964787), I've noticed that [test_android](https://github.com/facebook/react-native/actions/runs/8635097933/job/23673157303?pr=44026) actually failed on Github with this error: > Task :packages:react-native:ReactAndroid:compileDebugUnitTestKotlin e: file:///__w/react-native/react-native/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/image/ReactImagePropertyTest.kt:62:38 Smart cast to 'CatalystInstance' is impossible, because 'catalystInstanceMock' is a mutable property that could have been changed by this time Reviewed By: RSNara Differential Revision: D55982797 fbshipit-source-id: a49e766ae95e22603293326da93007d78250da6a
This commit is contained in:
committed by
Facebook GitHub Bot
parent
f7eaf63881
commit
3098613f6e
+9
-9
@@ -41,9 +41,9 @@ import org.robolectric.RuntimeEnvironment
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
class ReactImagePropertyTest {
|
||||
|
||||
private var context: BridgeReactContext? = null
|
||||
private var catalystInstanceMock: CatalystInstance? = null
|
||||
private var themeContext: ThemedReactContext? = null
|
||||
private lateinit var context: BridgeReactContext
|
||||
private lateinit var catalystInstanceMock: CatalystInstance
|
||||
private lateinit var themeContext: ThemedReactContext
|
||||
private lateinit var arguments: MockedStatic<Arguments>
|
||||
private lateinit var rnLog: MockedStatic<RNLog>
|
||||
|
||||
@@ -59,7 +59,7 @@ class ReactImagePropertyTest {
|
||||
SoLoader.setInTestMode()
|
||||
context = BridgeReactContext(RuntimeEnvironment.getApplication())
|
||||
catalystInstanceMock = createMockCatalystInstance()
|
||||
context!!.initializeWithInstance(catalystInstanceMock)
|
||||
context.initializeWithInstance(catalystInstanceMock)
|
||||
themeContext = ThemedReactContext(context, context, null, -1)
|
||||
Fresco.initialize(context)
|
||||
DisplayMetricsHolder.setWindowDisplayMetrics(DisplayMetrics())
|
||||
@@ -79,7 +79,7 @@ class ReactImagePropertyTest {
|
||||
@Test
|
||||
fun testBorderColor() {
|
||||
val viewManager = ReactImageManager()
|
||||
val view = viewManager.createViewInstance(themeContext!!)
|
||||
val view = viewManager.createViewInstance(themeContext)
|
||||
viewManager.updateProperties(
|
||||
view,
|
||||
buildStyles("src", JavaOnlyArray.of(JavaOnlyMap.of("uri", "http://mysite.com/mypic.jpg"))))
|
||||
@@ -106,7 +106,7 @@ class ReactImagePropertyTest {
|
||||
@Test
|
||||
fun testRoundedCorners() {
|
||||
val viewManager = ReactImageManager()
|
||||
val view = viewManager.createViewInstance(themeContext!!)
|
||||
val view = viewManager.createViewInstance(themeContext)
|
||||
viewManager.updateProperties(
|
||||
view,
|
||||
buildStyles("src", JavaOnlyArray.of(JavaOnlyMap.of("uri", "http://mysite.com/mypic.jpg"))))
|
||||
@@ -121,7 +121,7 @@ class ReactImagePropertyTest {
|
||||
@Test
|
||||
fun testAccessibilityFocus() {
|
||||
val viewManager = ReactImageManager()
|
||||
val view = viewManager.createViewInstance(themeContext!!)
|
||||
val view = viewManager.createViewInstance(themeContext)
|
||||
viewManager.setAccessible(view, true)
|
||||
Assert.assertEquals(true, view.isFocusable)
|
||||
}
|
||||
@@ -129,7 +129,7 @@ class ReactImagePropertyTest {
|
||||
@Test
|
||||
fun testTintColor() {
|
||||
val viewManager = ReactImageManager()
|
||||
val view = viewManager.createViewInstance(themeContext!!)
|
||||
val view = viewManager.createViewInstance(themeContext)
|
||||
Assert.assertNull(view.colorFilter)
|
||||
viewManager.updateProperties(view, buildStyles("tintColor", Color.argb(50, 0, 0, 255)))
|
||||
// Can't actually assert the specific color so this is the next best thing.
|
||||
@@ -142,7 +142,7 @@ class ReactImagePropertyTest {
|
||||
@Test
|
||||
fun testNullSrcs() {
|
||||
val viewManager = ReactImageManager()
|
||||
val view = viewManager.createViewInstance(themeContext!!)
|
||||
val view = viewManager.createViewInstance(themeContext)
|
||||
val sources = Arguments.createArray()
|
||||
val srcObj = Arguments.createMap()
|
||||
srcObj.putNull("uri")
|
||||
|
||||
Reference in New Issue
Block a user