@Override public List<Class<? extends JavaScriptModule>> createJSModules() { List<Class<? extends JavaScriptModule>> jsModules = new ArrayList<>(Arrays.asList( DeviceEventManagerModule.RCTDeviceEventEmitter.class, JSTimersExecution.class, RCTEventEmitter.class, RCTNativeAppEventEmitter.class, AppRegistry.class, com.facebook.react.bridge.Systrace.class, HMRClient.class)); if (ReactBuildConfig.DEBUG) { jsModules.add(DebugComponentOwnershipModule.RCTDebugComponentOwnership.class); jsModules.add(JSCHeapCapture.HeapCapture.class); jsModules.add(JSCSamplingProfiler.SamplingProfiler.class); } return jsModules; }
private void processPackage( ReactPackage reactPackage, NativeModuleRegistryBuilder nativeModuleRegistryBuilder, JavaScriptModuleRegistry.Builder jsModulesBuilder) { SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "processPackage") .arg("className", reactPackage.getClass().getSimpleName()) .flush(); if (reactPackage instanceof ReactPackageLogger) { ((ReactPackageLogger) reactPackage).startProcessPackage(); } nativeModuleRegistryBuilder.processPackage(reactPackage); for (Class<? extends JavaScriptModule> jsModuleClass : reactPackage.createJSModules()) { jsModulesBuilder.add(jsModuleClass); } if (reactPackage instanceof ReactPackageLogger) { ((ReactPackageLogger) reactPackage).endProcessPackage(); } Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); }
@Test public void testThatCompositeReturnsASumOfJSModules() { // Given CompositeReactPackage composite = new CompositeReactPackage(packageNo1, packageNo2); Class<? extends JavaScriptModule> moduleNo1 = mock(JavaScriptModuleNo1.class).getClass(); Class<? extends JavaScriptModule> moduleNo2 = mock(JavaScriptModuleNo2.class).getClass(); Class<? extends JavaScriptModule> moduleNo3 = mock(JavaScriptModuleNo3.class).getClass(); List<Class<? extends JavaScriptModule>> l1 = new ArrayList<>(); l1.add(moduleNo1); when(packageNo1.createJSModules()).thenReturn(l1); List<Class<? extends JavaScriptModule>> l2 = new ArrayList<>(); l2.add(moduleNo2); l2.add(moduleNo3); when(packageNo2.createJSModules()).thenReturn(l2); // When List<Class<? extends JavaScriptModule>> compositeModules = composite.createJSModules(); // Then // wrapping lists into sets to be order-independent List<Class<? extends JavaScriptModule>> l3 = new ArrayList<>(); l3.add(moduleNo1); l3.add(moduleNo2); l3.add(moduleNo3); Set<Class<? extends JavaScriptModule>> expected = new HashSet<>(l3); Set<Class<? extends JavaScriptModule>> actual = new HashSet<>(compositeModules); assertEquals(expected, actual); }
/** * {@inheritDoc} */ @Override public List<Class<? extends JavaScriptModule>> createJSModules() { final Set<Class<? extends JavaScriptModule>> moduleSet = new HashSet<>(); for (ReactPackage reactPackage: mChildReactPackages) { for (Class<? extends JavaScriptModule> jsModule: reactPackage.createJSModules()) { moduleSet.add(jsModule); } } return new ArrayList(moduleSet); }
public List<Class<? extends JavaScriptModule>> createJSModules() { return Collections.emptyList(); }
@Override public List<Class<? extends JavaScriptModule>> createJSModules() { return Collections.emptyList(); }
@Override public List<Class<? extends JavaScriptModule>> createJSModules() { return mSpecForTest.getExtraJSModulesForTest(); }
@Override public <T extends JavaScriptModule> T getJSModule(ExecutorToken executorToken, Class<T> jsInterface) { return Assertions.assertNotNull(mJSModuleRegistry) .getJavaScriptModule(this, executorToken, jsInterface); }
@Override public List<Class<? extends JavaScriptModule>> createJSModules() { return new ArrayList<>(); }