mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-12 10:26:49 +08:00
Remove UIImplementationProvider class and refactor UIManagerModule
Summary:
@public
This diff deprecates and deletes the UIImplementationProvider class.
It is not required to create an UIImplementation provider anymore, from now on the UIImplementation is created inside the UIManagerModule.
If you are using the UIImplementationProvider to create a ReactInstanceManager
e.g.:
```
ReactInstanceManager =
getReactInstanceManagerBuilder()
...
.setUIImplementationProvider(...)
...
.build();
```
Then you should just remove that line:
```
ReactInstanceManager =
getReactInstanceManagerBuilder()
.set.....
.build();
```
Reviewed By: achen1
Differential Revision: D8650376
fbshipit-source-id: 8d883295d8bf6578a99685edf6a2a84c6d0df0cf
This commit is contained in:
committed by
Facebook Github Bot
parent
a373bf705d
commit
506f920838
@@ -141,7 +141,7 @@ public class ReactPropConstantsTest {
|
||||
List<ViewManager> viewManagers = Arrays.<ViewManager>asList(new ViewManagerUnderTest());
|
||||
ReactApplicationContext reactContext = new ReactApplicationContext(RuntimeEnvironment.application);
|
||||
UIManagerModule uiManagerModule =
|
||||
new UIManagerModule(reactContext, viewManagers, new UIImplementationProvider(), 0);
|
||||
new UIManagerModule(reactContext, viewManagers, 0);
|
||||
Map<String, String> constants =
|
||||
(Map) valueAtPath(uiManagerModule.getConstants(), "SomeView", "NativeProps");
|
||||
assertThat(constants).isEqualTo(
|
||||
|
||||
@@ -8,14 +8,11 @@
|
||||
package com.facebook.react.uimanager;
|
||||
|
||||
import static org.fest.assertions.api.Assertions.assertThat;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyInt;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.common.MapBuilder;
|
||||
import com.facebook.react.uimanager.events.EventDispatcher;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -49,25 +46,17 @@ public class UIManagerModuleConstantsTest {
|
||||
private static final Map TWIRL_DIRECT_EVENT_MAP = MapBuilder.of("registrationName", "onTwirl");
|
||||
|
||||
private ReactApplicationContext mReactContext;
|
||||
private UIImplementationProvider mUIImplementationProvider;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mReactContext = new ReactApplicationContext(RuntimeEnvironment.application);
|
||||
mUIImplementationProvider = mock(UIImplementationProvider.class);
|
||||
when(mUIImplementationProvider.createUIImplementation(
|
||||
any(ReactApplicationContext.class),
|
||||
any(List.class),
|
||||
any(EventDispatcher.class),
|
||||
anyInt()))
|
||||
.thenReturn(mock(UIImplementation.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoCustomConstants() {
|
||||
List<ViewManager> viewManagers = Arrays.asList(mock(ViewManager.class));
|
||||
UIManagerModule uiManagerModule =
|
||||
new UIManagerModule(mReactContext, viewManagers, mUIImplementationProvider, 0);
|
||||
new UIManagerModule(mReactContext, viewManagers, 0);
|
||||
Map<String, Object> constants = uiManagerModule.getConstants();
|
||||
assertThat(constants)
|
||||
.containsKey(CUSTOM_BUBBLING_EVENT_TYPES)
|
||||
@@ -82,7 +71,7 @@ public class UIManagerModuleConstantsTest {
|
||||
when(mockViewManager.getExportedCustomBubblingEventTypeConstants())
|
||||
.thenReturn(MapBuilder.of("onTwirl", TWIRL_BUBBLING_EVENT_MAP));
|
||||
UIManagerModule uiManagerModule =
|
||||
new UIManagerModule(mReactContext, viewManagers, mUIImplementationProvider, 0);
|
||||
new UIManagerModule(mReactContext, viewManagers, 0);
|
||||
Map<String, Object> constants = uiManagerModule.getConstants();
|
||||
assertThat((Map) constants.get(CUSTOM_BUBBLING_EVENT_TYPES))
|
||||
.contains(MapEntry.entry("onTwirl", TWIRL_BUBBLING_EVENT_MAP))
|
||||
@@ -96,7 +85,7 @@ public class UIManagerModuleConstantsTest {
|
||||
when(mockViewManager.getExportedCustomDirectEventTypeConstants())
|
||||
.thenReturn(MapBuilder.of("onTwirl", TWIRL_DIRECT_EVENT_MAP));
|
||||
UIManagerModule uiManagerModule =
|
||||
new UIManagerModule(mReactContext, viewManagers, mUIImplementationProvider, 0);
|
||||
new UIManagerModule(mReactContext, viewManagers, 0);
|
||||
Map<String, Object> constants = uiManagerModule.getConstants();
|
||||
assertThat((Map) constants.get(CUSTOM_DIRECT_EVENT_TYPES))
|
||||
.contains(MapEntry.entry("onTwirl", TWIRL_DIRECT_EVENT_MAP))
|
||||
@@ -111,7 +100,7 @@ public class UIManagerModuleConstantsTest {
|
||||
when(mockViewManager.getExportedViewConstants())
|
||||
.thenReturn(MapBuilder.of("PhotoSizeType", MapBuilder.of("Small", 1, "Large", 2)));
|
||||
UIManagerModule uiManagerModule =
|
||||
new UIManagerModule(mReactContext, viewManagers, mUIImplementationProvider, 0);
|
||||
new UIManagerModule(mReactContext, viewManagers, 0);
|
||||
Map<String, Object> constants = uiManagerModule.getConstants();
|
||||
assertThat(constants).containsKey("RedPandaPhotoOfTheDayView");
|
||||
assertThat((Map) constants.get("RedPandaPhotoOfTheDayView")).containsKey("Constants");
|
||||
@@ -127,7 +116,7 @@ public class UIManagerModuleConstantsTest {
|
||||
when(mockViewManager.getNativeProps())
|
||||
.thenReturn(MapBuilder.of("fooProp", "number"));
|
||||
UIManagerModule uiManagerModule =
|
||||
new UIManagerModule(mReactContext, viewManagers, mUIImplementationProvider, 0);
|
||||
new UIManagerModule(mReactContext, viewManagers, 0);
|
||||
Map<String, Object> constants = uiManagerModule.getConstants();
|
||||
assertThat((String) valueAtPath(constants, "SomeView", "NativeProps", "fooProp"))
|
||||
.isEqualTo("number");
|
||||
@@ -159,7 +148,7 @@ public class UIManagerModuleConstantsTest {
|
||||
|
||||
List<ViewManager> viewManagers = Arrays.asList(managerX, managerY);
|
||||
UIManagerModule uiManagerModule =
|
||||
new UIManagerModule(mReactContext, viewManagers, mUIImplementationProvider, 0);
|
||||
new UIManagerModule(mReactContext, viewManagers, 0);
|
||||
Map<String, Object> constants = uiManagerModule.getConstants();
|
||||
assertThat((Map) constants.get(CUSTOM_DIRECT_EVENT_TYPES)).containsKey("onTwirl");
|
||||
|
||||
|
||||
@@ -814,7 +814,7 @@ public class UIManagerModuleTest {
|
||||
new ReactTextViewManager(),
|
||||
new ReactRawTextManager());
|
||||
UIManagerModule uiManagerModule =
|
||||
new UIManagerModule(mReactContext, viewManagers, new UIImplementationProvider(), 0);
|
||||
new UIManagerModule(mReactContext, viewManagers, 0);
|
||||
uiManagerModule.onHostResume();
|
||||
return uiManagerModule;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@ import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.bridge.ReactTestHelper;
|
||||
import com.facebook.react.modules.core.ChoreographerCompat;
|
||||
import com.facebook.react.modules.core.ReactChoreographer;
|
||||
import com.facebook.react.uimanager.UIImplementationProvider;
|
||||
import com.facebook.react.uimanager.UIManagerModule;
|
||||
import com.facebook.react.uimanager.ViewManager;
|
||||
import com.facebook.react.uimanager.ViewProps;
|
||||
@@ -428,7 +427,7 @@ public class ReactTextTest {
|
||||
new ReactRawTextManager(),
|
||||
});
|
||||
UIManagerModule uiManagerModule =
|
||||
new UIManagerModule(reactContext, viewManagers, new UIImplementationProvider(), 0);
|
||||
new UIManagerModule(reactContext, viewManagers, 0);
|
||||
uiManagerModule.onHostResume();
|
||||
return uiManagerModule;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.bridge.ReactTestHelper;
|
||||
import com.facebook.react.modules.core.ChoreographerCompat;
|
||||
import com.facebook.react.modules.core.ReactChoreographer;
|
||||
import com.facebook.react.uimanager.UIImplementationProvider;
|
||||
import com.facebook.react.uimanager.UIManagerModule;
|
||||
import com.facebook.react.uimanager.ViewManager;
|
||||
import com.facebook.react.uimanager.ViewProps;
|
||||
@@ -178,7 +177,7 @@ public class TextInputTest {
|
||||
new ReactTextInputManager(),
|
||||
});
|
||||
UIManagerModule uiManagerModule =
|
||||
new UIManagerModule(reactContext, viewManagers, new UIImplementationProvider(), 0);
|
||||
new UIManagerModule(reactContext, viewManagers, 0);
|
||||
uiManagerModule.onHostResume();
|
||||
return uiManagerModule;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user