diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/BackgroundStyleApplicator.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/BackgroundStyleApplicator.kt index c7d94a770c39..c3af3626ae6e 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/BackgroundStyleApplicator.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/BackgroundStyleApplicator.kt @@ -358,7 +358,7 @@ public object BackgroundStyleApplicator { * @param view The view to get the outline width from * @return The outline width in pixels, or null if not set */ - public fun getOutlineWidth(view: View): Float? = getOutlineDrawable(view)?.outlineOffset + public fun getOutlineWidth(view: View): Float? = getOutlineDrawable(view)?.outlineWidth /** * Sets box shadows for the view. diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/BackgroundStyleApplicatorTest.kt b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/BackgroundStyleApplicatorTest.kt new file mode 100644 index 000000000000..b836e4cfcf74 --- /dev/null +++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/BackgroundStyleApplicatorTest.kt @@ -0,0 +1,45 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +package com.facebook.react.uimanager + +import android.util.DisplayMetrics +import android.view.View +import org.assertj.core.api.Assertions.assertThat +import org.junit.After +import org.junit.Before +import org.junit.Test +import org.junit.runner.RunWith +import org.robolectric.RobolectricTestRunner +import org.robolectric.RuntimeEnvironment + +/** Tests for [BackgroundStyleApplicator] outline getters. */ +@RunWith(RobolectricTestRunner::class) +class BackgroundStyleApplicatorTest { + + private lateinit var view: View + + @Before + fun setUp() { + DisplayMetricsHolder.setScreenDisplayMetrics(DisplayMetrics().apply { density = 2f }) + view = View(RuntimeEnvironment.getApplication()) + } + + @After + fun tearDown() { + DisplayMetricsHolder.setScreenDisplayMetrics(null) + } + + @Test + fun getOutlineWidthReturnsWidthNotOffset() { + BackgroundStyleApplicator.setOutlineWidth(view, 3f) + BackgroundStyleApplicator.setOutlineOffset(view, 8f) + + assertThat(BackgroundStyleApplicator.getOutlineWidth(view)).isEqualTo(6f) + assertThat(BackgroundStyleApplicator.getOutlineOffset(view)).isEqualTo(16f) + } +}