Skip to content

Commit 7435ea2

Browse files
author
HURRAEY
committed
fix(android): convert outlineColor values before delegation
1 parent 08c3233 commit 7435ea2

2 files changed

Lines changed: 51 additions & 1 deletion

File tree

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManagerDelegate.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,12 @@ public abstract class BaseViewManagerDelegate<
104104
mViewManager.setAccessibilityLabelledBy(view, dynamicFromObject)
105105
}
106106
ViewProps.OPACITY -> mViewManager.setOpacity(view, (value as Double?)?.toFloat() ?: 1.0f)
107-
ViewProps.OUTLINE_COLOR -> mViewManager.setOutlineColor(view, value as Int?)
107+
ViewProps.OUTLINE_COLOR ->
108+
mViewManager.setOutlineColor(
109+
view,
110+
// outlineColor의 nullable 계약을 보존하기 위해 기본값이 없는 변환을 사용한다.
111+
ColorPropConverter.getColor(value, view.context),
112+
)
108113

109114
ViewProps.OUTLINE_OFFSET ->
110115
mViewManager.setOutlineOffset(
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
package com.facebook.react.uimanager;
9+
10+
import static org.mockito.Mockito.mock;
11+
import static org.mockito.Mockito.verify;
12+
13+
import com.facebook.react.bridge.BridgeReactContext;
14+
import com.facebook.react.views.view.ReactViewGroup;
15+
import com.facebook.react.views.view.ReactViewManager;
16+
import org.junit.Before;
17+
import org.junit.Test;
18+
import org.junit.runner.RunWith;
19+
import org.robolectric.RobolectricTestRunner;
20+
import org.robolectric.RuntimeEnvironment;
21+
22+
@RunWith(RobolectricTestRunner.class)
23+
public class BaseViewManagerDelegateTest {
24+
private ReactViewManager viewManager;
25+
private ReactViewGroup view;
26+
private BaseViewManagerDelegate<ReactViewGroup, ReactViewManager> delegate;
27+
28+
@Before
29+
public void setUp() {
30+
viewManager = mock(ReactViewManager.class);
31+
BridgeReactContext context = new BridgeReactContext(RuntimeEnvironment.getApplication());
32+
ThemedReactContext themedReactContext = new ThemedReactContext(context, context, null, -1);
33+
view = new ReactViewGroup(themedReactContext);
34+
delegate = new BaseViewManagerDelegate<>(viewManager) {};
35+
}
36+
37+
@Test
38+
public void setOutlineColorConvertsDoubleToInt() {
39+
int color = 0xFF336699;
40+
41+
delegate.setProperty(view, ViewProps.OUTLINE_COLOR, (double) color);
42+
43+
verify(viewManager).setOutlineColor(view, color);
44+
}
45+
}

0 commit comments

Comments
 (0)