Pass minTimeLeftInFrameForNonBatchedOperationMs from above

Reviewed By: AaaChiuuu

Differential Revision: D5658066

fbshipit-source-id: f89a8bcfc180210f7361b03f718f65b1d59cbf85
This commit is contained in:
Alexey Lang 2017-08-20 17:23:50 -07:00 committed by Facebook Github Bot
parent a777517651
commit 992777b765
23 changed files with 268 additions and 296 deletions

View File

@ -8,12 +8,6 @@
package com.facebook.react.tests; package com.facebook.react.tests;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import com.facebook.react.bridge.BaseJavaModule; import com.facebook.react.bridge.BaseJavaModule;
import com.facebook.react.bridge.CatalystInstance; import com.facebook.react.bridge.CatalystInstance;
import com.facebook.react.bridge.Dynamic; import com.facebook.react.bridge.Dynamic;
@ -40,7 +34,11 @@ import com.facebook.react.uimanager.UIImplementationProvider;
import com.facebook.react.uimanager.UIManagerModule; import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.ViewManager; import com.facebook.react.uimanager.ViewManager;
import com.facebook.react.views.view.ReactViewManager; import com.facebook.react.views.view.ReactViewManager;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.junit.Ignore; import org.junit.Ignore;
/** /**
@ -87,11 +85,8 @@ public class CatalystNativeJSToJavaParametersTestCase extends ReactIntegrationTe
List<ViewManager> viewManagers = Arrays.<ViewManager>asList( List<ViewManager> viewManagers = Arrays.<ViewManager>asList(
new ReactViewManager()); new ReactViewManager());
final UIManagerModule mUIManager = new UIManagerModule( final UIManagerModule mUIManager =
getContext(), new UIManagerModule(getContext(), viewManagers, new UIImplementationProvider(), false, 0);
viewManagers,
new UIImplementationProvider(),
false);
UiThreadUtil.runOnUiThread( UiThreadUtil.runOnUiThread(
new Runnable() { new Runnable() {
@Override @Override

View File

@ -8,9 +8,6 @@
package com.facebook.react.tests; package com.facebook.react.tests;
import java.util.Arrays;
import java.util.List;
import com.facebook.react.bridge.CatalystInstance; import com.facebook.react.bridge.CatalystInstance;
import com.facebook.react.bridge.JavaScriptModule; import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.bridge.ObjectAlreadyConsumedException; import com.facebook.react.bridge.ObjectAlreadyConsumedException;
@ -29,7 +26,8 @@ import com.facebook.react.uimanager.UIImplementationProvider;
import com.facebook.react.uimanager.UIManagerModule; import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.ViewManager; import com.facebook.react.uimanager.ViewManager;
import com.facebook.react.views.view.ReactViewManager; import com.facebook.react.views.view.ReactViewManager;
import java.util.Arrays;
import java.util.List;
import org.junit.Ignore; import org.junit.Ignore;
/** /**
@ -64,11 +62,8 @@ public class CatalystNativeJavaToJSArgumentsTestCase extends ReactIntegrationTes
List<ViewManager> viewManagers = Arrays.<ViewManager>asList( List<ViewManager> viewManagers = Arrays.<ViewManager>asList(
new ReactViewManager()); new ReactViewManager());
final UIManagerModule mUIManager = new UIManagerModule( final UIManagerModule mUIManager =
getContext(), new UIManagerModule(getContext(), viewManagers, new UIImplementationProvider(), false, 0);
viewManagers,
new UIImplementationProvider(),
false);
UiThreadUtil.runOnUiThread( UiThreadUtil.runOnUiThread(
new Runnable() { new Runnable() {
@Override @Override

View File

@ -8,8 +8,6 @@
package com.facebook.react.tests; package com.facebook.react.tests;
import java.util.ArrayList;
import com.facebook.react.bridge.BaseJavaModule; import com.facebook.react.bridge.BaseJavaModule;
import com.facebook.react.bridge.CatalystInstance; import com.facebook.react.bridge.CatalystInstance;
import com.facebook.react.bridge.JavaScriptModule; import com.facebook.react.bridge.JavaScriptModule;
@ -18,9 +16,9 @@ import com.facebook.react.bridge.WritableArray;
import com.facebook.react.bridge.WritableMap; import com.facebook.react.bridge.WritableMap;
import com.facebook.react.bridge.WritableNativeArray; import com.facebook.react.bridge.WritableNativeArray;
import com.facebook.react.bridge.WritableNativeMap; import com.facebook.react.bridge.WritableNativeMap;
import com.facebook.react.module.annotations.ReactModule;
import com.facebook.react.modules.appstate.AppStateModule; import com.facebook.react.modules.appstate.AppStateModule;
import com.facebook.react.modules.deviceinfo.DeviceInfoModule; import com.facebook.react.modules.deviceinfo.DeviceInfoModule;
import com.facebook.react.module.annotations.ReactModule;
import com.facebook.react.testing.AssertModule; import com.facebook.react.testing.AssertModule;
import com.facebook.react.testing.FakeWebSocketModule; import com.facebook.react.testing.FakeWebSocketModule;
import com.facebook.react.testing.ReactIntegrationTestCase; import com.facebook.react.testing.ReactIntegrationTestCase;
@ -28,7 +26,7 @@ import com.facebook.react.testing.ReactTestHelper;
import com.facebook.react.uimanager.UIImplementationProvider; import com.facebook.react.uimanager.UIImplementationProvider;
import com.facebook.react.uimanager.UIManagerModule; import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.ViewManager; import com.facebook.react.uimanager.ViewManager;
import java.util.ArrayList;
import org.junit.Ignore; import org.junit.Ignore;
/** /**
@ -113,11 +111,9 @@ public class CatalystNativeJavaToJSReturnValuesTestCase extends ReactIntegration
protected void setUp() throws Exception { protected void setUp() throws Exception {
super.setUp(); super.setUp();
final UIManagerModule mUIManager = new UIManagerModule( final UIManagerModule mUIManager =
getContext(), new UIManagerModule(
new ArrayList<ViewManager>(), getContext(), new ArrayList<ViewManager>(), new UIImplementationProvider(), false, 0);
new UIImplementationProvider(),
false);
mAssertModule = new AssertModule(); mAssertModule = new AssertModule();

View File

@ -9,21 +9,20 @@
package com.facebook.react.tests; package com.facebook.react.tests;
import java.util.Arrays;
import java.util.List;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.TextView; import android.widget.TextView;
import com.facebook.react.ReactRootView; import com.facebook.react.ReactRootView;
import com.facebook.react.bridge.JavaScriptModule; import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.bridge.UiThreadUtil; import com.facebook.react.bridge.UiThreadUtil;
import com.facebook.react.modules.appstate.AppStateModule; import com.facebook.react.modules.appstate.AppStateModule;
import com.facebook.react.modules.deviceinfo.DeviceInfoModule; import com.facebook.react.modules.deviceinfo.DeviceInfoModule;
import com.facebook.react.modules.systeminfo.AndroidInfoModule; import com.facebook.react.modules.systeminfo.AndroidInfoModule;
import com.facebook.react.testing.FakeWebSocketModule;
import com.facebook.react.testing.ReactIntegrationTestCase;
import com.facebook.react.testing.ReactTestHelper;
import com.facebook.react.uimanager.PixelUtil; import com.facebook.react.uimanager.PixelUtil;
import com.facebook.react.uimanager.UIImplementationProvider; import com.facebook.react.uimanager.UIImplementationProvider;
import com.facebook.react.uimanager.UIManagerModule; import com.facebook.react.uimanager.UIManagerModule;
@ -31,9 +30,8 @@ import com.facebook.react.uimanager.ViewManager;
import com.facebook.react.views.text.ReactRawTextManager; import com.facebook.react.views.text.ReactRawTextManager;
import com.facebook.react.views.text.ReactTextViewManager; import com.facebook.react.views.text.ReactTextViewManager;
import com.facebook.react.views.view.ReactViewManager; import com.facebook.react.views.view.ReactViewManager;
import com.facebook.react.testing.FakeWebSocketModule; import java.util.Arrays;
import com.facebook.react.testing.ReactIntegrationTestCase; import java.util.List;
import com.facebook.react.testing.ReactTestHelper;
/** /**
* Test case for basic {@link UIManagerModule} functionality. * Test case for basic {@link UIManagerModule} functionality.
@ -80,11 +78,8 @@ public class CatalystUIManagerTestCase extends ReactIntegrationTestCase {
new ReactViewManager(), new ReactViewManager(),
new ReactTextViewManager(), new ReactTextViewManager(),
new ReactRawTextManager()); new ReactRawTextManager());
uiManager = new UIManagerModule( uiManager =
getContext(), new UIManagerModule(getContext(), viewManagers, new UIImplementationProvider(), false, 0);
viewManagers,
new UIImplementationProvider(),
false);
UiThreadUtil.runOnUiThread(new Runnable() { UiThreadUtil.runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {

View File

@ -49,7 +49,8 @@ public class JSLocaleTest extends ReactIntegrationTestCase {
getContext(), getContext(),
viewManagers, viewManagers,
new UIImplementationProvider(), new UIImplementationProvider(),
false); false,
0);
UiThreadUtil.runOnUiThread( UiThreadUtil.runOnUiThread(
new Runnable() { new Runnable() {
@Override @Override

View File

@ -8,10 +8,6 @@
package com.facebook.react.tests; package com.facebook.react.tests;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import android.content.res.Resources; import android.content.res.Resources;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.util.TypedValue; import android.util.TypedValue;
@ -19,7 +15,6 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import com.facebook.react.ReactRootView; import com.facebook.react.ReactRootView;
import com.facebook.react.bridge.CatalystInstance; import com.facebook.react.bridge.CatalystInstance;
import com.facebook.react.bridge.JavaScriptModule; import com.facebook.react.bridge.JavaScriptModule;
@ -27,14 +22,17 @@ import com.facebook.react.bridge.UiThreadUtil;
import com.facebook.react.modules.appstate.AppStateModule; import com.facebook.react.modules.appstate.AppStateModule;
import com.facebook.react.modules.deviceinfo.DeviceInfoModule; import com.facebook.react.modules.deviceinfo.DeviceInfoModule;
import com.facebook.react.modules.systeminfo.AndroidInfoModule; import com.facebook.react.modules.systeminfo.AndroidInfoModule;
import com.facebook.react.testing.FakeWebSocketModule;
import com.facebook.react.testing.ReactIntegrationTestCase;
import com.facebook.react.testing.ReactTestHelper;
import com.facebook.react.uimanager.UIImplementationProvider; import com.facebook.react.uimanager.UIImplementationProvider;
import com.facebook.react.uimanager.UIManagerModule; import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.ViewManager; import com.facebook.react.uimanager.ViewManager;
import com.facebook.react.views.progressbar.ReactProgressBarViewManager; import com.facebook.react.views.progressbar.ReactProgressBarViewManager;
import com.facebook.react.views.view.ReactViewManager; import com.facebook.react.views.view.ReactViewManager;
import com.facebook.react.testing.FakeWebSocketModule; import java.util.Arrays;
import com.facebook.react.testing.ReactIntegrationTestCase; import java.util.HashMap;
import com.facebook.react.testing.ReactTestHelper; import java.util.List;
/** /**
* Test to verify that Progress bar renders as a view of the right size * Test to verify that Progress bar renders as a view of the right size
@ -70,11 +68,8 @@ public class ProgressBarTestCase extends ReactIntegrationTestCase {
List<ViewManager> viewManagers = Arrays.<ViewManager>asList( List<ViewManager> viewManagers = Arrays.<ViewManager>asList(
new ReactViewManager(), new ReactViewManager(),
new ReactProgressBarViewManager()); new ReactProgressBarViewManager());
mUIManager = new UIManagerModule( mUIManager =
getContext(), new UIManagerModule(getContext(), viewManagers, new UIImplementationProvider(), false, 0);
viewManagers,
new UIImplementationProvider(),
false);
UiThreadUtil.runOnUiThread( UiThreadUtil.runOnUiThread(
new Runnable() { new Runnable() {
@Override @Override

View File

@ -8,13 +8,9 @@
package com.facebook.react.tests; package com.facebook.react.tests;
import java.util.Arrays;
import java.util.List;
import android.graphics.Color; import android.graphics.Color;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import com.facebook.react.ReactRootView; import com.facebook.react.ReactRootView;
import com.facebook.react.bridge.CatalystInstance; import com.facebook.react.bridge.CatalystInstance;
import com.facebook.react.bridge.JavaScriptModule; import com.facebook.react.bridge.JavaScriptModule;
@ -22,15 +18,17 @@ import com.facebook.react.bridge.UiThreadUtil;
import com.facebook.react.modules.appstate.AppStateModule; import com.facebook.react.modules.appstate.AppStateModule;
import com.facebook.react.modules.deviceinfo.DeviceInfoModule; import com.facebook.react.modules.deviceinfo.DeviceInfoModule;
import com.facebook.react.modules.systeminfo.AndroidInfoModule; import com.facebook.react.modules.systeminfo.AndroidInfoModule;
import com.facebook.react.testing.FakeWebSocketModule;
import com.facebook.react.testing.ReactIntegrationTestCase;
import com.facebook.react.testing.ReactTestHelper;
import com.facebook.react.uimanager.PixelUtil; import com.facebook.react.uimanager.PixelUtil;
import com.facebook.react.uimanager.UIImplementationProvider; import com.facebook.react.uimanager.UIImplementationProvider;
import com.facebook.react.uimanager.UIManagerModule; import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.ViewManager; import com.facebook.react.uimanager.ViewManager;
import com.facebook.react.views.view.ReactViewGroup; import com.facebook.react.views.view.ReactViewGroup;
import com.facebook.react.views.view.ReactViewManager; import com.facebook.react.views.view.ReactViewManager;
import com.facebook.react.testing.FakeWebSocketModule; import java.util.Arrays;
import com.facebook.react.testing.ReactIntegrationTestCase; import java.util.List;
import com.facebook.react.testing.ReactTestHelper;
public class ViewRenderingTestCase extends ReactIntegrationTestCase { public class ViewRenderingTestCase extends ReactIntegrationTestCase {
@ -51,11 +49,8 @@ public class ViewRenderingTestCase extends ReactIntegrationTestCase {
super.setUp(); super.setUp();
List<ViewManager> viewManagers = Arrays.<ViewManager>asList(new ReactViewManager()); List<ViewManager> viewManagers = Arrays.<ViewManager>asList(new ReactViewManager());
final UIManagerModule uiManager = new UIManagerModule( final UIManagerModule uiManager =
getContext(), new UIManagerModule(getContext(), viewManagers, new UIImplementationProvider(), false, 0);
viewManagers,
new UIImplementationProvider(),
false);
UiThreadUtil.runOnUiThread( UiThreadUtil.runOnUiThread(
new Runnable() { new Runnable() {
@Override @Override

View File

@ -9,10 +9,10 @@
package com.facebook.react; package com.facebook.react;
import javax.inject.Provider; import static com.facebook.react.bridge.ReactMarkerConstants.CREATE_UI_MANAGER_MODULE_END;
import static com.facebook.react.bridge.ReactMarkerConstants.CREATE_UI_MANAGER_MODULE_START;
import java.util.ArrayList; import static com.facebook.react.bridge.ReactMarkerConstants.PROCESS_CORE_REACT_PACKAGE_END;
import java.util.List; import static com.facebook.react.bridge.ReactMarkerConstants.PROCESS_CORE_REACT_PACKAGE_START;
import com.facebook.react.bridge.ModuleSpec; import com.facebook.react.bridge.ModuleSpec;
import com.facebook.react.bridge.NativeModule; import com.facebook.react.bridge.NativeModule;
@ -36,11 +36,9 @@ import com.facebook.react.uimanager.UIImplementationProvider;
import com.facebook.react.uimanager.UIManagerModule; import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.ViewManager; import com.facebook.react.uimanager.ViewManager;
import com.facebook.systrace.Systrace; import com.facebook.systrace.Systrace;
import java.util.ArrayList;
import static com.facebook.react.bridge.ReactMarkerConstants.CREATE_UI_MANAGER_MODULE_END; import java.util.List;
import static com.facebook.react.bridge.ReactMarkerConstants.CREATE_UI_MANAGER_MODULE_START; import javax.inject.Provider;
import static com.facebook.react.bridge.ReactMarkerConstants.PROCESS_CORE_REACT_PACKAGE_END;
import static com.facebook.react.bridge.ReactMarkerConstants.PROCESS_CORE_REACT_PACKAGE_START;
/** /**
* This module should be removed following the completion of an experiment into splitting this into * This module should be removed following the completion of an experiment into splitting this into
* three modules to allow for more light-weight instantiations of the bridge without UIManager * three modules to allow for more light-weight instantiations of the bridge without UIManager
@ -74,16 +72,19 @@ import static com.facebook.react.bridge.ReactMarkerConstants.PROCESS_CORE_REACT_
private final DefaultHardwareBackBtnHandler mHardwareBackBtnHandler; private final DefaultHardwareBackBtnHandler mHardwareBackBtnHandler;
private final UIImplementationProvider mUIImplementationProvider; private final UIImplementationProvider mUIImplementationProvider;
private final boolean mLazyViewManagersEnabled; private final boolean mLazyViewManagersEnabled;
private final int mMinTimeLeftInFrameForNonBatchedOperationMs;
CoreModulesPackage( CoreModulesPackage(
ReactInstanceManager reactInstanceManager, ReactInstanceManager reactInstanceManager,
DefaultHardwareBackBtnHandler hardwareBackBtnHandler, DefaultHardwareBackBtnHandler hardwareBackBtnHandler,
UIImplementationProvider uiImplementationProvider, UIImplementationProvider uiImplementationProvider,
boolean lazyViewManagersEnabled) { boolean lazyViewManagersEnabled,
int minTimeLeftInFrameForNonBatchedOperationMs) {
mReactInstanceManager = reactInstanceManager; mReactInstanceManager = reactInstanceManager;
mHardwareBackBtnHandler = hardwareBackBtnHandler; mHardwareBackBtnHandler = hardwareBackBtnHandler;
mUIImplementationProvider = uiImplementationProvider; mUIImplementationProvider = uiImplementationProvider;
mLazyViewManagersEnabled = lazyViewManagersEnabled; mLazyViewManagersEnabled = lazyViewManagersEnabled;
mMinTimeLeftInFrameForNonBatchedOperationMs = minTimeLeftInFrameForNonBatchedOperationMs;
} }
@Override @Override
@ -192,7 +193,8 @@ import static com.facebook.react.bridge.ReactMarkerConstants.PROCESS_CORE_REACT_
reactContext, reactContext,
viewManagersList, viewManagersList,
mUIImplementationProvider, mUIImplementationProvider,
mLazyViewManagersEnabled); mLazyViewManagersEnabled,
mMinTimeLeftInFrameForNonBatchedOperationMs);
} finally { } finally {
Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_END); ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_END);

View File

@ -46,6 +46,7 @@ import com.facebook.react.bridge.JSBundleLoader;
import com.facebook.react.bridge.JSCJavaScriptExecutor; import com.facebook.react.bridge.JSCJavaScriptExecutor;
import com.facebook.react.bridge.JavaJSExecutor; import com.facebook.react.bridge.JavaJSExecutor;
import com.facebook.react.bridge.JavaScriptExecutor; import com.facebook.react.bridge.JavaScriptExecutor;
import com.facebook.react.bridge.NativeArray;
import com.facebook.react.bridge.NativeModuleCallExceptionHandler; import com.facebook.react.bridge.NativeModuleCallExceptionHandler;
import com.facebook.react.bridge.NativeModuleRegistry; import com.facebook.react.bridge.NativeModuleRegistry;
import com.facebook.react.bridge.NotThreadSafeBridgeIdleDebugListener; import com.facebook.react.bridge.NotThreadSafeBridgeIdleDebugListener;
@ -55,7 +56,6 @@ import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.ReactMarker; import com.facebook.react.bridge.ReactMarker;
import com.facebook.react.bridge.ReactMarkerConstants; import com.facebook.react.bridge.ReactMarkerConstants;
import com.facebook.react.bridge.UiThreadUtil; import com.facebook.react.bridge.UiThreadUtil;
import com.facebook.react.bridge.NativeArray;
import com.facebook.react.bridge.queue.ReactQueueConfigurationSpec; import com.facebook.react.bridge.queue.ReactQueueConfigurationSpec;
import com.facebook.react.common.LifecycleState; import com.facebook.react.common.LifecycleState;
import com.facebook.react.common.ReactConstants; import com.facebook.react.common.ReactConstants;
@ -149,6 +149,7 @@ public class ReactInstanceManager {
private final boolean mLazyViewManagersEnabled; private final boolean mLazyViewManagersEnabled;
private final boolean mUseSeparateUIBackgroundThread; private final boolean mUseSeparateUIBackgroundThread;
private final int mMinNumShakes; private final int mMinNumShakes;
private final int mMinTimeLeftInFrameForNonBatchedOperationMs;
private final ReactInstanceDevCommandsHandler mDevInterface = private final ReactInstanceDevCommandsHandler mDevInterface =
new ReactInstanceDevCommandsHandler() { new ReactInstanceDevCommandsHandler() {
@ -224,7 +225,8 @@ public class ReactInstanceManager {
boolean useSeparateUIBackgroundThread, boolean useSeparateUIBackgroundThread,
int minNumShakes, int minNumShakes,
boolean splitPackagesEnabled, boolean splitPackagesEnabled,
boolean useOnlyDefaultPackages) { boolean useOnlyDefaultPackages,
int minTimeLeftInFrameForNonBatchedOperationMs) {
Log.d(ReactConstants.TAG, "ReactInstanceManager.ctor()"); Log.d(ReactConstants.TAG, "ReactInstanceManager.ctor()");
initializeSoLoaderIfNecessary(applicationContext); initializeSoLoaderIfNecessary(applicationContext);
@ -254,6 +256,7 @@ public class ReactInstanceManager {
mJSCConfig = jscConfig; mJSCConfig = jscConfig;
mLazyNativeModulesEnabled = lazyNativeModulesEnabled; mLazyNativeModulesEnabled = lazyNativeModulesEnabled;
mLazyViewManagersEnabled = lazyViewManagersEnabled; mLazyViewManagersEnabled = lazyViewManagersEnabled;
mMinTimeLeftInFrameForNonBatchedOperationMs = minTimeLeftInFrameForNonBatchedOperationMs;
mUseSeparateUIBackgroundThread = useSeparateUIBackgroundThread; mUseSeparateUIBackgroundThread = useSeparateUIBackgroundThread;
mMinNumShakes = minNumShakes; mMinNumShakes = minNumShakes;
@ -263,7 +266,8 @@ public class ReactInstanceManager {
this, this,
mBackBtnHandler, mBackBtnHandler,
mUIImplementationProvider, mUIImplementationProvider,
mLazyViewManagersEnabled); mLazyViewManagersEnabled,
mMinTimeLeftInFrameForNonBatchedOperationMs);
mPackages.add(coreModulesPackage); mPackages.add(coreModulesPackage);
} else { } else {
mPackages.add(new BridgeCorePackage(this, mBackBtnHandler)); mPackages.add(new BridgeCorePackage(this, mBackBtnHandler));
@ -275,7 +279,8 @@ public class ReactInstanceManager {
new ReactNativeCorePackage( new ReactNativeCorePackage(
this, this,
mUIImplementationProvider, mUIImplementationProvider,
mLazyViewManagersEnabled)); mLazyViewManagersEnabled,
mMinTimeLeftInFrameForNonBatchedOperationMs));
} }
} }
mPackages.addAll(packages); mPackages.addAll(packages);

View File

@ -45,6 +45,7 @@ public class ReactInstanceManagerBuilder {
private int mMinNumShakes = 1; private int mMinNumShakes = 1;
private boolean mEnableSplitPackage; private boolean mEnableSplitPackage;
private boolean mUseOnlyDefaultPackages; private boolean mUseOnlyDefaultPackages;
private int mMinTimeLeftInFrameForNonBatchedOperationMs = -1;
/* package protected */ ReactInstanceManagerBuilder() { /* package protected */ ReactInstanceManagerBuilder() {
} }
@ -216,6 +217,12 @@ public class ReactInstanceManagerBuilder {
return this; return this;
} }
public ReactInstanceManagerBuilder setMinTimeLeftInFrameForNonBatchedOperationMs(
int minTimeLeftInFrameForNonBatchedOperationMs) {
mMinTimeLeftInFrameForNonBatchedOperationMs = minTimeLeftInFrameForNonBatchedOperationMs;
return this;
}
/** /**
* Instantiates a new {@link ReactInstanceManager}. * Instantiates a new {@link ReactInstanceManager}.
* Before calling {@code build}, the following must be called: * Before calling {@code build}, the following must be called:
@ -248,9 +255,10 @@ public class ReactInstanceManagerBuilder {
mApplication, mApplication,
mCurrentActivity, mCurrentActivity,
mDefaultHardwareBackBtnHandler, mDefaultHardwareBackBtnHandler,
(mJSBundleLoader == null && mJSBundleAssetUrl != null) ? (mJSBundleLoader == null && mJSBundleAssetUrl != null)
JSBundleLoader.createAssetLoader(mApplication, mJSBundleAssetUrl, false /*Asynchronous*/) : ? JSBundleLoader.createAssetLoader(
mJSBundleLoader, mApplication, mJSBundleAssetUrl, false /*Asynchronous*/)
: mJSBundleLoader,
mJSMainModulePath, mJSMainModulePath,
mPackages, mPackages,
mUseDeveloperSupport, mUseDeveloperSupport,
@ -266,6 +274,7 @@ public class ReactInstanceManagerBuilder {
mUseSeparateUIBackgroundThread, mUseSeparateUIBackgroundThread,
mMinNumShakes, mMinNumShakes,
mEnableSplitPackage, mEnableSplitPackage,
mUseOnlyDefaultPackages); mUseOnlyDefaultPackages,
mMinTimeLeftInFrameForNonBatchedOperationMs);
} }
} }

View File

@ -9,10 +9,8 @@
package com.facebook.react; package com.facebook.react;
import javax.inject.Provider; import static com.facebook.react.bridge.ReactMarkerConstants.CREATE_UI_MANAGER_MODULE_END;
import static com.facebook.react.bridge.ReactMarkerConstants.CREATE_UI_MANAGER_MODULE_START;
import java.util.ArrayList;
import java.util.List;
import com.facebook.react.bridge.ModuleSpec; import com.facebook.react.bridge.ModuleSpec;
import com.facebook.react.bridge.NativeModule; import com.facebook.react.bridge.NativeModule;
@ -24,9 +22,9 @@ import com.facebook.react.uimanager.UIImplementationProvider;
import com.facebook.react.uimanager.UIManagerModule; import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.ViewManager; import com.facebook.react.uimanager.ViewManager;
import com.facebook.systrace.Systrace; import com.facebook.systrace.Systrace;
import java.util.ArrayList;
import static com.facebook.react.bridge.ReactMarkerConstants.CREATE_UI_MANAGER_MODULE_END; import java.util.List;
import static com.facebook.react.bridge.ReactMarkerConstants.CREATE_UI_MANAGER_MODULE_START; import javax.inject.Provider;
/** /**
* Package defining core framework modules for initializing ReactNative (e.g. UIManager). It should be used for modules that * Package defining core framework modules for initializing ReactNative (e.g. UIManager). It should be used for modules that
@ -43,14 +41,17 @@ public class ReactNativeCorePackage extends LazyReactPackage {
private final ReactInstanceManager mReactInstanceManager; private final ReactInstanceManager mReactInstanceManager;
private final UIImplementationProvider mUIImplementationProvider; private final UIImplementationProvider mUIImplementationProvider;
private final boolean mLazyViewManagersEnabled; private final boolean mLazyViewManagersEnabled;
private final int mMinTimeLeftInFrameForNonBatchedOperationMs;
public ReactNativeCorePackage( public ReactNativeCorePackage(
ReactInstanceManager reactInstanceManager, ReactInstanceManager reactInstanceManager,
UIImplementationProvider uiImplementationProvider, UIImplementationProvider uiImplementationProvider,
boolean lazyViewManagersEnabled) { boolean lazyViewManagersEnabled,
int minTimeLeftInFrameForNonBatchedOperationMs) {
mReactInstanceManager = reactInstanceManager; mReactInstanceManager = reactInstanceManager;
mUIImplementationProvider = uiImplementationProvider; mUIImplementationProvider = uiImplementationProvider;
mLazyViewManagersEnabled = lazyViewManagersEnabled; mLazyViewManagersEnabled = lazyViewManagersEnabled;
mMinTimeLeftInFrameForNonBatchedOperationMs = minTimeLeftInFrameForNonBatchedOperationMs;
} }
@Override @Override
@ -86,7 +87,8 @@ public class ReactNativeCorePackage extends LazyReactPackage {
reactContext, reactContext,
viewManagersList, viewManagersList,
mUIImplementationProvider, mUIImplementationProvider,
mLazyViewManagersEnabled); mLazyViewManagersEnabled,
mMinTimeLeftInFrameForNonBatchedOperationMs);
} finally { } finally {
Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_END); ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_END);

View File

@ -22,12 +22,11 @@ import com.facebook.react.uimanager.ViewManager;
import com.facebook.react.uimanager.ViewManagerRegistry; import com.facebook.react.uimanager.ViewManagerRegistry;
import com.facebook.react.uimanager.events.EventDispatcher; import com.facebook.react.uimanager.events.EventDispatcher;
import com.facebook.yoga.YogaDirection; import com.facebook.yoga.YogaDirection;
import javax.annotation.Nullable;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.annotation.Nullable;
/** /**
* FlatUIImplementation builds on top of UIImplementation and allows pre-creating everything * FlatUIImplementation builds on top of UIImplementation and allows pre-creating everything
@ -88,7 +87,8 @@ public class FlatUIImplementation extends UIImplementation {
ReactApplicationContext reactContext, ReactApplicationContext reactContext,
List<ViewManager> viewManagers, List<ViewManager> viewManagers,
EventDispatcher eventDispatcher, EventDispatcher eventDispatcher,
boolean memoryImprovementEnabled) { boolean memoryImprovementEnabled,
int minTimeLeftInFrameForNonBatchedOperationMs) {
Map<String, ViewManager> viewManagerMap = buildViewManagerMap(viewManagers); Map<String, ViewManager> viewManagerMap = buildViewManagerMap(viewManagers);
@ -107,9 +107,9 @@ public class FlatUIImplementation extends UIImplementation {
ViewManagerRegistry viewManagerRegistry = new ViewManagerRegistry(viewManagerMap); ViewManagerRegistry viewManagerRegistry = new ViewManagerRegistry(viewManagerMap);
FlatNativeViewHierarchyManager nativeViewHierarchyManager = new FlatNativeViewHierarchyManager( FlatNativeViewHierarchyManager nativeViewHierarchyManager = new FlatNativeViewHierarchyManager(
viewManagerRegistry); viewManagerRegistry);
FlatUIViewOperationQueue operationsQueue = new FlatUIViewOperationQueue( FlatUIViewOperationQueue operationsQueue =
reactContext, new FlatUIViewOperationQueue(
nativeViewHierarchyManager); reactContext, nativeViewHierarchyManager, minTimeLeftInFrameForNonBatchedOperationMs);
return new FlatUIImplementation( return new FlatUIImplementation(
reactContext, reactContext,
imageViewManager, imageViewManager,

View File

@ -9,12 +9,11 @@
package com.facebook.react.flat; package com.facebook.react.flat;
import java.util.List;
import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.UIImplementationProvider; import com.facebook.react.uimanager.UIImplementationProvider;
import com.facebook.react.uimanager.ViewManager; import com.facebook.react.uimanager.ViewManager;
import com.facebook.react.uimanager.events.EventDispatcher; import com.facebook.react.uimanager.events.EventDispatcher;
import java.util.List;
/** /**
* UIImplementationProvider that creates instances of {@link FlatUIImplementation}. * UIImplementationProvider that creates instances of {@link FlatUIImplementation}.
@ -35,11 +34,13 @@ public final class FlatUIImplementationProvider extends UIImplementationProvider
public FlatUIImplementation createUIImplementation( public FlatUIImplementation createUIImplementation(
ReactApplicationContext reactContext, ReactApplicationContext reactContext,
List<ViewManager> viewManagers, List<ViewManager> viewManagers,
EventDispatcher eventDispatcher) { EventDispatcher eventDispatcher,
int minTimeLeftInFrameForNonBatchedOperationMs) {
return FlatUIImplementation.createInstance( return FlatUIImplementation.createInstance(
reactContext, reactContext,
viewManagers, viewManagers,
eventDispatcher, eventDispatcher,
mMemoryImprovementEnabled); mMemoryImprovementEnabled,
minTimeLeftInFrameForNonBatchedOperationMs);
} }
} }

View File

@ -9,14 +9,9 @@
package com.facebook.react.flat; package com.facebook.react.flat;
import javax.annotation.Nullable;
import java.util.ArrayList;
import android.util.SparseIntArray; import android.util.SparseIntArray;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import com.facebook.react.bridge.Callback; import com.facebook.react.bridge.Callback;
import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.ReadableArray;
@ -25,6 +20,8 @@ import com.facebook.react.uimanager.NoSuchNativeViewException;
import com.facebook.react.uimanager.PixelUtil; import com.facebook.react.uimanager.PixelUtil;
import com.facebook.react.uimanager.TouchTargetHelper; import com.facebook.react.uimanager.TouchTargetHelper;
import com.facebook.react.uimanager.UIViewOperationQueue; import com.facebook.react.uimanager.UIViewOperationQueue;
import java.util.ArrayList;
import javax.annotation.Nullable;
/** /**
* FlatUIViewOperationQueue extends {@link UIViewOperationQueue} to add * FlatUIViewOperationQueue extends {@link UIViewOperationQueue} to add
@ -399,8 +396,9 @@ import com.facebook.react.uimanager.UIViewOperationQueue;
public FlatUIViewOperationQueue( public FlatUIViewOperationQueue(
ReactApplicationContext reactContext, ReactApplicationContext reactContext,
FlatNativeViewHierarchyManager nativeViewHierarchyManager) { FlatNativeViewHierarchyManager nativeViewHierarchyManager,
super(reactContext, nativeViewHierarchyManager); int minTimeLeftInFrameForNonBatchedOperationMs) {
super(reactContext, nativeViewHierarchyManager, minTimeLeftInFrameForNonBatchedOperationMs);
mNativeViewHierarchyManager = nativeViewHierarchyManager; mNativeViewHierarchyManager = nativeViewHierarchyManager;
} }

View File

@ -50,18 +50,27 @@ public class UIImplementation {
public UIImplementation( public UIImplementation(
ReactApplicationContext reactContext, ReactApplicationContext reactContext,
List<ViewManager> viewManagers, List<ViewManager> viewManagers,
EventDispatcher eventDispatcher) { EventDispatcher eventDispatcher,
this(reactContext, new ViewManagerRegistry(viewManagers), eventDispatcher); int minTimeLeftInFrameForNonBatchedOperationMs) {
this(
reactContext,
new ViewManagerRegistry(viewManagers),
eventDispatcher,
minTimeLeftInFrameForNonBatchedOperationMs);
} }
private UIImplementation( private UIImplementation(
ReactApplicationContext reactContext, ReactApplicationContext reactContext,
ViewManagerRegistry viewManagers, ViewManagerRegistry viewManagers,
EventDispatcher eventDispatcher) { EventDispatcher eventDispatcher,
int minTimeLeftInFrameForNonBatchedOperationMs) {
this( this(
reactContext, reactContext,
viewManagers, viewManagers,
new UIViewOperationQueue(reactContext, new NativeViewHierarchyManager(viewManagers)), new UIViewOperationQueue(
reactContext,
new NativeViewHierarchyManager(viewManagers),
minTimeLeftInFrameForNonBatchedOperationMs),
eventDispatcher); eventDispatcher);
} }

View File

@ -8,10 +8,9 @@
*/ */
package com.facebook.react.uimanager; package com.facebook.react.uimanager;
import java.util.List;
import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.events.EventDispatcher; import com.facebook.react.uimanager.events.EventDispatcher;
import java.util.List;
/** /**
* Provides UIImplementation to use in {@link UIManagerModule}. * Provides UIImplementation to use in {@link UIManagerModule}.
@ -20,7 +19,9 @@ public class UIImplementationProvider {
public UIImplementation createUIImplementation( public UIImplementation createUIImplementation(
ReactApplicationContext reactContext, ReactApplicationContext reactContext,
List<ViewManager> viewManagers, List<ViewManager> viewManagers,
EventDispatcher eventDispatcher) { EventDispatcher eventDispatcher,
return new UIImplementation(reactContext, viewManagers, eventDispatcher); int minTimeLeftInFrameForNonBatchedOperationMs) {
return new UIImplementation(
reactContext, viewManagers, eventDispatcher, minTimeLeftInFrameForNonBatchedOperationMs);
} }
} }

View File

@ -85,13 +85,18 @@ public class UIManagerModule extends ReactContextBaseJavaModule implements
ReactApplicationContext reactContext, ReactApplicationContext reactContext,
List<ViewManager> viewManagerList, List<ViewManager> viewManagerList,
UIImplementationProvider uiImplementationProvider, UIImplementationProvider uiImplementationProvider,
boolean lazyViewManagersEnabled) { boolean lazyViewManagersEnabled,
int minTimeLeftInFrameForNonBatchedOperationMs) {
super(reactContext); super(reactContext);
DisplayMetricsHolder.initDisplayMetricsIfNotInitialized(reactContext); DisplayMetricsHolder.initDisplayMetricsIfNotInitialized(reactContext);
mEventDispatcher = new EventDispatcher(reactContext); mEventDispatcher = new EventDispatcher(reactContext);
mModuleConstants = createConstants(viewManagerList, lazyViewManagersEnabled); mModuleConstants = createConstants(viewManagerList, lazyViewManagersEnabled);
mUIImplementation = uiImplementationProvider mUIImplementation =
.createUIImplementation(reactContext, viewManagerList, mEventDispatcher); uiImplementationProvider.createUIImplementation(
reactContext,
viewManagerList,
mEventDispatcher,
minTimeLeftInFrameForNonBatchedOperationMs);
reactContext.addLifecycleEventListener(this); reactContext.addLifecycleEventListener(this);
} }

View File

@ -46,6 +46,8 @@ import javax.annotation.concurrent.GuardedBy;
*/ */
public class UIViewOperationQueue { public class UIViewOperationQueue {
public static final int DEFAULT_MIN_TIME_LEFT_IN_FRAME_FOR_NONBATCHED_OPERATION_MS = 8;
private final int[] mMeasureBuffer = new int[4]; private final int[] mMeasureBuffer = new int[4];
/** /**
@ -554,10 +556,16 @@ public class UIViewOperationQueue {
public UIViewOperationQueue( public UIViewOperationQueue(
ReactApplicationContext reactContext, ReactApplicationContext reactContext,
NativeViewHierarchyManager nativeViewHierarchyManager) { NativeViewHierarchyManager nativeViewHierarchyManager,
int minTimeLeftInFrameForNonBatchedOperationMs) {
mNativeViewHierarchyManager = nativeViewHierarchyManager; mNativeViewHierarchyManager = nativeViewHierarchyManager;
mAnimationRegistry = nativeViewHierarchyManager.getAnimationRegistry(); mAnimationRegistry = nativeViewHierarchyManager.getAnimationRegistry();
mDispatchUIFrameCallback = new DispatchUIFrameCallback(reactContext); mDispatchUIFrameCallback =
new DispatchUIFrameCallback(
reactContext,
minTimeLeftInFrameForNonBatchedOperationMs == -1
? DEFAULT_MIN_TIME_LEFT_IN_FRAME_FOR_NONBATCHED_OPERATION_MS
: minTimeLeftInFrameForNonBatchedOperationMs);
mReactApplicationContext = reactContext; mReactApplicationContext = reactContext;
} }
@ -936,11 +944,13 @@ public class UIViewOperationQueue {
*/ */
private class DispatchUIFrameCallback extends GuardedFrameCallback { private class DispatchUIFrameCallback extends GuardedFrameCallback {
private static final int MIN_TIME_LEFT_IN_FRAME_TO_SCHEDULE_MORE_WORK_MS = 8;
private static final int FRAME_TIME_MS = 16; private static final int FRAME_TIME_MS = 16;
private final int mMinTimeLeftInFrameForNonBatchedOperationMs;
private DispatchUIFrameCallback(ReactContext reactContext) { private DispatchUIFrameCallback(
ReactContext reactContext, int minTimeLeftInFrameForNonBatchedOperationMs) {
super(reactContext); super(reactContext);
mMinTimeLeftInFrameForNonBatchedOperationMs = minTimeLeftInFrameForNonBatchedOperationMs;
} }
@Override @Override
@ -984,7 +994,7 @@ public class UIViewOperationQueue {
private void dispatchPendingNonBatchedOperations(long frameTimeNanos) { private void dispatchPendingNonBatchedOperations(long frameTimeNanos) {
while (true) { while (true) {
long timeLeftInFrame = FRAME_TIME_MS - ((System.nanoTime() - frameTimeNanos) / 1000000); long timeLeftInFrame = FRAME_TIME_MS - ((System.nanoTime() - frameTimeNanos) / 1000000);
if (timeLeftInFrame < MIN_TIME_LEFT_IN_FRAME_TO_SCHEDULE_MORE_WORK_MS) { if (timeLeftInFrame < mMinTimeLeftInFrameForNonBatchedOperationMs) {
break; break;
} }

View File

@ -9,19 +9,19 @@
package com.facebook.react.uimanager; package com.facebook.react.uimanager;
import java.util.Arrays; import static org.fest.assertions.api.Assertions.assertThat;
import java.util.List; import static org.fest.assertions.api.Assertions.fail;
import java.util.Map;
import android.view.View; import android.view.View;
import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap; import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.common.MapBuilder; import com.facebook.react.common.MapBuilder;
import com.facebook.react.uimanager.annotations.ReactProp; import com.facebook.react.uimanager.annotations.ReactProp;
import com.facebook.react.uimanager.annotations.ReactPropGroup; import com.facebook.react.uimanager.annotations.ReactPropGroup;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -30,9 +30,6 @@ import org.powermock.modules.junit4.rule.PowerMockRule;
import org.robolectric.RobolectricTestRunner; import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment; import org.robolectric.RuntimeEnvironment;
import static org.fest.assertions.api.Assertions.assertThat;
import static org.fest.assertions.api.Assertions.fail;
/** /**
* Verifies that prop constants are generated properly based on {@code ReactProp} annotation. * Verifies that prop constants are generated properly based on {@code ReactProp} annotation.
*/ */
@ -145,11 +142,8 @@ public class ReactPropConstantsTest {
public void testNativePropsIncludeCorrectTypes() { public void testNativePropsIncludeCorrectTypes() {
List<ViewManager> viewManagers = Arrays.<ViewManager>asList(new ViewManagerUnderTest()); List<ViewManager> viewManagers = Arrays.<ViewManager>asList(new ViewManagerUnderTest());
ReactApplicationContext reactContext = new ReactApplicationContext(RuntimeEnvironment.application); ReactApplicationContext reactContext = new ReactApplicationContext(RuntimeEnvironment.application);
UIManagerModule uiManagerModule = new UIManagerModule( UIManagerModule uiManagerModule =
reactContext, new UIManagerModule(reactContext, viewManagers, new UIImplementationProvider(), false, 0);
viewManagers,
new UIImplementationProvider(),
false);
Map<String, String> constants = Map<String, String> constants =
(Map) valueAtPath(uiManagerModule.getConstants(), "SomeView", "NativeProps"); (Map) valueAtPath(uiManagerModule.getConstants(), "SomeView", "NativeProps");
assertThat(constants).isEqualTo( assertThat(constants).isEqualTo(

View File

@ -9,14 +9,18 @@
package com.facebook.react.uimanager; package com.facebook.react.uimanager;
import java.util.Arrays; import static org.fest.assertions.api.Assertions.assertThat;
import java.util.List; import static org.mockito.Matchers.any;
import java.util.Map; 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.bridge.ReactApplicationContext;
import com.facebook.react.common.MapBuilder; import com.facebook.react.common.MapBuilder;
import com.facebook.react.uimanager.events.EventDispatcher; import com.facebook.react.uimanager.events.EventDispatcher;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import org.fest.assertions.data.MapEntry; import org.fest.assertions.data.MapEntry;
import org.junit.Before; import org.junit.Before;
import org.junit.Rule; import org.junit.Rule;
@ -27,11 +31,6 @@ import org.powermock.modules.junit4.rule.PowerMockRule;
import org.robolectric.RobolectricTestRunner; import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment; import org.robolectric.RuntimeEnvironment;
import static org.fest.assertions.api.Assertions.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@RunWith(RobolectricTestRunner.class) @RunWith(RobolectricTestRunner.class)
@PowerMockIgnore({"org.mockito.*", "org.robolectric.*", "android.*"}) @PowerMockIgnore({"org.mockito.*", "org.robolectric.*", "android.*"})
public class UIManagerModuleConstantsTest { public class UIManagerModuleConstantsTest {
@ -61,18 +60,16 @@ public class UIManagerModuleConstantsTest {
when(mUIImplementationProvider.createUIImplementation( when(mUIImplementationProvider.createUIImplementation(
any(ReactApplicationContext.class), any(ReactApplicationContext.class),
any(List.class), any(List.class),
any(EventDispatcher.class))) any(EventDispatcher.class),
anyInt()))
.thenReturn(mock(UIImplementation.class)); .thenReturn(mock(UIImplementation.class));
} }
@Test @Test
public void testNoCustomConstants() { public void testNoCustomConstants() {
List<ViewManager> viewManagers = Arrays.asList(mock(ViewManager.class)); List<ViewManager> viewManagers = Arrays.asList(mock(ViewManager.class));
UIManagerModule uiManagerModule = new UIManagerModule( UIManagerModule uiManagerModule =
mReactContext, new UIManagerModule(mReactContext, viewManagers, mUIImplementationProvider, false, 0);
viewManagers,
mUIImplementationProvider,
false);
Map<String, Object> constants = uiManagerModule.getConstants(); Map<String, Object> constants = uiManagerModule.getConstants();
assertThat(constants) assertThat(constants)
.containsKey(CUSTOM_BUBBLING_EVENT_TYPES) .containsKey(CUSTOM_BUBBLING_EVENT_TYPES)
@ -86,11 +83,8 @@ public class UIManagerModuleConstantsTest {
List<ViewManager> viewManagers = Arrays.asList(mockViewManager); List<ViewManager> viewManagers = Arrays.asList(mockViewManager);
when(mockViewManager.getExportedCustomBubblingEventTypeConstants()) when(mockViewManager.getExportedCustomBubblingEventTypeConstants())
.thenReturn(MapBuilder.of("onTwirl", TWIRL_BUBBLING_EVENT_MAP)); .thenReturn(MapBuilder.of("onTwirl", TWIRL_BUBBLING_EVENT_MAP));
UIManagerModule uiManagerModule = new UIManagerModule( UIManagerModule uiManagerModule =
mReactContext, new UIManagerModule(mReactContext, viewManagers, mUIImplementationProvider, false, 0);
viewManagers,
mUIImplementationProvider,
false);
Map<String, Object> constants = uiManagerModule.getConstants(); Map<String, Object> constants = uiManagerModule.getConstants();
assertThat((Map) constants.get(CUSTOM_BUBBLING_EVENT_TYPES)) assertThat((Map) constants.get(CUSTOM_BUBBLING_EVENT_TYPES))
.contains(MapEntry.entry("onTwirl", TWIRL_BUBBLING_EVENT_MAP)) .contains(MapEntry.entry("onTwirl", TWIRL_BUBBLING_EVENT_MAP))
@ -103,11 +97,8 @@ public class UIManagerModuleConstantsTest {
List<ViewManager> viewManagers = Arrays.asList(mockViewManager); List<ViewManager> viewManagers = Arrays.asList(mockViewManager);
when(mockViewManager.getExportedCustomDirectEventTypeConstants()) when(mockViewManager.getExportedCustomDirectEventTypeConstants())
.thenReturn(MapBuilder.of("onTwirl", TWIRL_DIRECT_EVENT_MAP)); .thenReturn(MapBuilder.of("onTwirl", TWIRL_DIRECT_EVENT_MAP));
UIManagerModule uiManagerModule = new UIManagerModule( UIManagerModule uiManagerModule =
mReactContext, new UIManagerModule(mReactContext, viewManagers, mUIImplementationProvider, false, 0);
viewManagers,
mUIImplementationProvider,
false);
Map<String, Object> constants = uiManagerModule.getConstants(); Map<String, Object> constants = uiManagerModule.getConstants();
assertThat((Map) constants.get(CUSTOM_DIRECT_EVENT_TYPES)) assertThat((Map) constants.get(CUSTOM_DIRECT_EVENT_TYPES))
.contains(MapEntry.entry("onTwirl", TWIRL_DIRECT_EVENT_MAP)) .contains(MapEntry.entry("onTwirl", TWIRL_DIRECT_EVENT_MAP))
@ -121,11 +112,8 @@ public class UIManagerModuleConstantsTest {
when(mockViewManager.getName()).thenReturn("RedPandaPhotoOfTheDayView"); when(mockViewManager.getName()).thenReturn("RedPandaPhotoOfTheDayView");
when(mockViewManager.getExportedViewConstants()) when(mockViewManager.getExportedViewConstants())
.thenReturn(MapBuilder.of("PhotoSizeType", MapBuilder.of("Small", 1, "Large", 2))); .thenReturn(MapBuilder.of("PhotoSizeType", MapBuilder.of("Small", 1, "Large", 2)));
UIManagerModule uiManagerModule = new UIManagerModule( UIManagerModule uiManagerModule =
mReactContext, new UIManagerModule(mReactContext, viewManagers, mUIImplementationProvider, false, 0);
viewManagers,
mUIImplementationProvider,
false);
Map<String, Object> constants = uiManagerModule.getConstants(); Map<String, Object> constants = uiManagerModule.getConstants();
assertThat(constants).containsKey("RedPandaPhotoOfTheDayView"); assertThat(constants).containsKey("RedPandaPhotoOfTheDayView");
assertThat((Map) constants.get("RedPandaPhotoOfTheDayView")).containsKey("Constants"); assertThat((Map) constants.get("RedPandaPhotoOfTheDayView")).containsKey("Constants");
@ -140,11 +128,8 @@ public class UIManagerModuleConstantsTest {
when(mockViewManager.getName()).thenReturn("SomeView"); when(mockViewManager.getName()).thenReturn("SomeView");
when(mockViewManager.getNativeProps()) when(mockViewManager.getNativeProps())
.thenReturn(MapBuilder.of("fooProp", "number")); .thenReturn(MapBuilder.of("fooProp", "number"));
UIManagerModule uiManagerModule = new UIManagerModule( UIManagerModule uiManagerModule =
mReactContext, new UIManagerModule(mReactContext, viewManagers, mUIImplementationProvider, false, 0);
viewManagers,
mUIImplementationProvider,
false);
Map<String, Object> constants = uiManagerModule.getConstants(); Map<String, Object> constants = uiManagerModule.getConstants();
assertThat((String) valueAtPath(constants, "SomeView", "NativeProps", "fooProp")) assertThat((String) valueAtPath(constants, "SomeView", "NativeProps", "fooProp"))
.isEqualTo("number"); .isEqualTo("number");
@ -175,11 +160,8 @@ public class UIManagerModuleConstantsTest {
MapBuilder.of("keyToOverride", "innerValueY", "extraKey", "valueY")))); MapBuilder.of("keyToOverride", "innerValueY", "extraKey", "valueY"))));
List<ViewManager> viewManagers = Arrays.asList(managerX, managerY); List<ViewManager> viewManagers = Arrays.asList(managerX, managerY);
UIManagerModule uiManagerModule = new UIManagerModule( UIManagerModule uiManagerModule =
mReactContext, new UIManagerModule(mReactContext, viewManagers, mUIImplementationProvider, false, 0);
viewManagers,
mUIImplementationProvider,
false);
Map<String, Object> constants = uiManagerModule.getConstants(); Map<String, Object> constants = uiManagerModule.getConstants();
assertThat((Map) constants.get(CUSTOM_DIRECT_EVENT_TYPES)).containsKey("onTwirl"); assertThat((Map) constants.get(CUSTOM_DIRECT_EVENT_TYPES)).containsKey("onTwirl");

View File

@ -9,15 +9,19 @@
package com.facebook.react.uimanager; package com.facebook.react.uimanager;
import java.util.ArrayList; import static org.fest.assertions.api.Assertions.assertThat;
import java.util.Arrays; import static org.mockito.Matchers.any;
import java.util.List; import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.graphics.Color; import android.graphics.Color;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.TextView; import android.widget.TextView;
import com.facebook.react.ReactRootView; import com.facebook.react.ReactRootView;
import com.facebook.react.animation.Animation; import com.facebook.react.animation.Animation;
import com.facebook.react.animation.AnimationPropertyUpdater; import com.facebook.react.animation.AnimationPropertyUpdater;
@ -35,7 +39,9 @@ import com.facebook.react.views.text.ReactTextShadowNode;
import com.facebook.react.views.text.ReactTextViewManager; import com.facebook.react.views.text.ReactTextViewManager;
import com.facebook.react.views.view.ReactViewGroup; import com.facebook.react.views.view.ReactViewGroup;
import com.facebook.react.views.view.ReactViewManager; import com.facebook.react.views.view.ReactViewManager;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.junit.Before; import org.junit.Before;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
@ -49,15 +55,6 @@ import org.powermock.modules.junit4.rule.PowerMockRule;
import org.robolectric.RobolectricTestRunner; import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment; import org.robolectric.RuntimeEnvironment;
import static org.fest.assertions.api.Assertions.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
/** /**
* Tests for {@link UIManagerModule}. * Tests for {@link UIManagerModule}.
*/ */
@ -818,11 +815,8 @@ public class UIManagerModuleTest {
new ReactViewManager(), new ReactViewManager(),
new ReactTextViewManager(), new ReactTextViewManager(),
new ReactRawTextManager()); new ReactRawTextManager());
UIManagerModule uiManagerModule = new UIManagerModule( UIManagerModule uiManagerModule =
mReactContext, new UIManagerModule(mReactContext, viewManagers, new UIImplementationProvider(), false, 0);
viewManagers,
new UIImplementationProvider(),
false);
uiManagerModule.onHostResume(); uiManagerModule.onHostResume();
return uiManagerModule; return uiManagerModule;
} }

View File

@ -9,9 +9,10 @@
package com.facebook.react.views.text; package com.facebook.react.views.text;
import java.util.ArrayList; import static org.fest.assertions.api.Assertions.assertThat;
import java.util.Arrays; import static org.mockito.Matchers.any;
import java.util.List; import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.graphics.Color; import android.graphics.Color;
@ -24,7 +25,6 @@ import android.text.style.AbsoluteSizeSpan;
import android.text.style.StrikethroughSpan; import android.text.style.StrikethroughSpan;
import android.text.style.UnderlineSpan; import android.text.style.UnderlineSpan;
import android.widget.TextView; import android.widget.TextView;
import com.facebook.react.ReactRootView; import com.facebook.react.ReactRootView;
import com.facebook.react.bridge.Arguments; import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.JavaOnlyArray; import com.facebook.react.bridge.JavaOnlyArray;
@ -38,7 +38,9 @@ import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.ViewManager; import com.facebook.react.uimanager.ViewManager;
import com.facebook.react.uimanager.ViewProps; import com.facebook.react.uimanager.ViewProps;
import com.facebook.react.views.view.ReactViewBackgroundDrawable; import com.facebook.react.views.view.ReactViewBackgroundDrawable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.junit.Before; import org.junit.Before;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
@ -52,11 +54,6 @@ import org.powermock.modules.junit4.rule.PowerMockRule;
import org.robolectric.RobolectricTestRunner; import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment; import org.robolectric.RuntimeEnvironment;
import static org.fest.assertions.api.Assertions.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
/** /**
* Tests for {@link UIManagerModule} specifically for React Text/RawText. * Tests for {@link UIManagerModule} specifically for React Text/RawText.
*/ */
@ -431,11 +428,8 @@ public class ReactTextTest {
new ReactTextViewManager(), new ReactTextViewManager(),
new ReactRawTextManager(), new ReactRawTextManager(),
}); });
UIManagerModule uiManagerModule = new UIManagerModule( UIManagerModule uiManagerModule =
reactContext, new UIManagerModule(reactContext, viewManagers, new UIImplementationProvider(), false, 0);
viewManagers,
new UIImplementationProvider(),
false);
uiManagerModule.onHostResume(); uiManagerModule.onHostResume();
return uiManagerModule; return uiManagerModule;
} }

View File

@ -9,12 +9,12 @@
package com.facebook.react.views.textinput; package com.facebook.react.views.textinput;
import java.util.ArrayList; import static org.fest.assertions.api.Assertions.assertThat;
import java.util.Arrays; import static org.mockito.Matchers.any;
import java.util.List; import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import android.widget.EditText; import android.widget.EditText;
import com.facebook.react.ReactRootView; import com.facebook.react.ReactRootView;
import com.facebook.react.bridge.Arguments; import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.JavaOnlyArray; import com.facebook.react.bridge.JavaOnlyArray;
@ -27,7 +27,9 @@ import com.facebook.react.uimanager.UIImplementationProvider;
import com.facebook.react.uimanager.UIManagerModule; import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.ViewManager; import com.facebook.react.uimanager.ViewManager;
import com.facebook.react.uimanager.ViewProps; import com.facebook.react.uimanager.ViewProps;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.junit.Before; import org.junit.Before;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
@ -41,11 +43,6 @@ import org.powermock.modules.junit4.rule.PowerMockRule;
import org.robolectric.RobolectricTestRunner; import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment; import org.robolectric.RuntimeEnvironment;
import static org.fest.assertions.api.Assertions.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
/** /**
* Tests for TextInput. * Tests for TextInput.
*/ */
@ -182,11 +179,8 @@ public class TextInputTest {
new ViewManager[] { new ViewManager[] {
new ReactTextInputManager(), new ReactTextInputManager(),
}); });
UIManagerModule uiManagerModule = new UIManagerModule( UIManagerModule uiManagerModule =
reactContext, new UIManagerModule(reactContext, viewManagers, new UIImplementationProvider(), false, 0);
viewManagers,
new UIImplementationProvider(),
false);
uiManagerModule.onHostResume(); uiManagerModule.onHostResume();
return uiManagerModule; return uiManagerModule;
} }