Skip to content
Open
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 @@ -104,7 +104,12 @@ public abstract class BaseViewManagerDelegate<
mViewManager.setAccessibilityLabelledBy(view, dynamicFromObject)
}
ViewProps.OPACITY -> mViewManager.setOpacity(view, (value as Double?)?.toFloat() ?: 1.0f)
ViewProps.OUTLINE_COLOR -> mViewManager.setOutlineColor(view, value as Int?)
ViewProps.OUTLINE_COLOR ->
mViewManager.setOutlineColor(
view,
// Use the overload without a default value to preserve outlineColor's nullable contract.
ColorPropConverter.getColor(value, view.context),
)

ViewProps.OUTLINE_OFFSET ->
mViewManager.setOutlineOffset(
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 static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;

import com.facebook.react.bridge.BridgeReactContext;
import com.facebook.react.views.view.ReactViewGroup;
import com.facebook.react.views.view.ReactViewManager;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;

@RunWith(RobolectricTestRunner.class)
public class BaseViewManagerDelegateTest {
private ReactViewManager viewManager;
private ReactViewGroup view;
private BaseViewManagerDelegate<ReactViewGroup, ReactViewManager> delegate;

@Before
public void setUp() {
viewManager = mock(ReactViewManager.class);
BridgeReactContext context = new BridgeReactContext(RuntimeEnvironment.getApplication());
ThemedReactContext themedReactContext = new ThemedReactContext(context, context, null, -1);
view = new ReactViewGroup(themedReactContext);
delegate = new BaseViewManagerDelegate<>(viewManager) {};
}

@Test
public void setOutlineColorConvertsDoubleToInt() {
int color = 0xFF336699;

delegate.setProperty(view, ViewProps.OUTLINE_COLOR, (double) color);

verify(viewManager).setOutlineColor(view, color);
}
}