Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
}
}
Loading