@Test
  public void testPropsApplied() {
    UIManagerModule uiManager = getUIManagerModule();

    ReactRootView rootView = new ReactRootView(RuntimeEnvironment.application);
    int rootTag = uiManager.addMeasuredRootView(rootView);
    int textInputTag = rootTag + 1;
    final String hintStr = "placeholder text";

    uiManager.createView(
        textInputTag,
        ReactTextInputManager.REACT_CLASS,
        rootTag,
        SimpleMap.of(ViewProps.FONT_SIZE, 13.37, ViewProps.HEIGHT, 20.0, "placeholder", hintStr));

    uiManager.manageChildren(
        rootTag, null, null, SimpleArray.of(textInputTag), SimpleArray.of(0), null);

    uiManager.onBatchComplete();
    executePendingChoreographerCallbacks();

    EditText editText = (EditText) rootView.getChildAt(0);
    assertThat(editText.getHint()).isEqualTo(hintStr);
    assertThat(editText.getTextSize()).isEqualTo((float) Math.ceil(13.37));
    assertThat(editText.getHeight()).isEqualTo(20);
  }
 public UIManagerModule getUIManagerModule() {
   ReactApplicationContext reactContext = ReactTestHelper.createCatalystContextForTest();
   List<ViewManager> viewManagers =
       Arrays.asList(
           new ViewManager[] {
             new ReactTextInputManager(),
           });
   DisplayMetrics displayMetrics = reactContext.getResources().getDisplayMetrics();
   DisplayMetricsHolder.setDisplayMetrics(displayMetrics);
   UIManagerModule uiManagerModule =
       new UIManagerModule(
           reactContext, viewManagers, new UIImplementation(reactContext, viewManagers));
   uiManagerModule.onHostResume();
   return uiManagerModule;
 }
  private void attachMeasuredRootViewToInstance(
      ReactRootView rootView, CatalystInstance catalystInstance) {
    UiThreadUtil.assertOnUiThread();

    // Reset view content as it's going to be populated by the application content from JS
    rootView.removeAllViews();
    rootView.setId(View.NO_ID);

    UIManagerModule uiManagerModule = catalystInstance.getNativeModule(UIManagerModule.class);
    int rootTag = uiManagerModule.addMeasuredRootView(rootView);
    @Nullable Bundle launchOptions = rootView.getLaunchOptions();
    WritableMap initialProps =
        launchOptions != null ? Arguments.fromBundle(launchOptions) : Arguments.createMap();
    String jsAppModuleName = rootView.getJSModuleName();

    WritableNativeMap appParams = new WritableNativeMap();
    appParams.putDouble("rootTag", rootTag);
    appParams.putMap("initialProps", initialProps);
    catalystInstance.getJSModule(AppRegistry.class).runApplication(jsAppModuleName, appParams);
  }
  private ReactRootView createText(
      UIManagerModule uiManager, JavaOnlyMap textProps, JavaOnlyMap rawTextProps) {
    ReactRootView rootView = new ReactRootView(RuntimeEnvironment.application);
    int rootTag = uiManager.addMeasuredRootView(rootView);
    int textTag = rootTag + 1;
    int rawTextTag = textTag + 1;

    uiManager.createView(textTag, ReactTextViewManager.REACT_CLASS, rootTag, textProps);
    uiManager.createView(rawTextTag, ReactRawTextManager.REACT_CLASS, rootTag, rawTextProps);

    uiManager.manageChildren(
        textTag, null, null, JavaOnlyArray.of(rawTextTag), JavaOnlyArray.of(0), null);

    uiManager.manageChildren(
        rootTag, null, null, JavaOnlyArray.of(textTag), JavaOnlyArray.of(0), null);

    uiManager.onBatchComplete();
    executePendingChoreographerCallbacks();
    return rootView;
  }
  @Test
  public void testTouchEmitter() {
    ReactInstanceManager instanceManager = mock(ReactInstanceManager.class);
    when(instanceManager.getCurrentReactContext()).thenReturn(mReactContext);

    UIManagerModule uiManager = mock(UIManagerModule.class);
    EventDispatcher eventDispatcher = mock(EventDispatcher.class);
    RCTEventEmitter eventEmitterModuleMock = mock(RCTEventEmitter.class);
    when(mCatalystInstanceMock.getNativeModule(UIManagerModule.class)).thenReturn(uiManager);
    when(uiManager.getEventDispatcher()).thenReturn(eventDispatcher);

    int rootViewId = 7;

    ReactRootView rootView = new ReactRootView(mReactContext);
    rootView.setId(rootViewId);
    rootView.startReactApplication(instanceManager, "");
    rootView.simulateAttachForTesting();

    long ts = new Date().getTime();

    // Test ACTION_DOWN event
    rootView.onTouchEvent(MotionEvent.obtain(100, ts, MotionEvent.ACTION_DOWN, 0, 0, 0));

    ArgumentCaptor<Event> downEventCaptor = ArgumentCaptor.forClass(Event.class);
    verify(eventDispatcher).dispatchEvent(downEventCaptor.capture());
    verifyNoMoreInteractions(eventDispatcher);

    downEventCaptor.getValue().dispatch(eventEmitterModuleMock);

    ArgumentCaptor<SimpleArray> downActionTouchesArgCaptor =
        ArgumentCaptor.forClass(SimpleArray.class);
    verify(eventEmitterModuleMock)
        .receiveTouches(
            eq("topTouchStart"), downActionTouchesArgCaptor.capture(), any(SimpleArray.class));
    verifyNoMoreInteractions(eventEmitterModuleMock);

    assertThat(downActionTouchesArgCaptor.getValue().size()).isEqualTo(1);
    assertThat(downActionTouchesArgCaptor.getValue().getMap(0))
        .isEqualTo(
            SimpleMap.of(
                "pageX",
                0.,
                "pageY",
                0.,
                "locationX",
                0.,
                "locationY",
                0.,
                "target",
                rootViewId,
                "timeStamp",
                (double) ts,
                "identifier",
                0.));

    // Test ACTION_UP event
    reset(eventEmitterModuleMock, eventDispatcher);

    ArgumentCaptor<Event> upEventCaptor = ArgumentCaptor.forClass(Event.class);
    ArgumentCaptor<SimpleArray> upActionTouchesArgCaptor =
        ArgumentCaptor.forClass(SimpleArray.class);

    rootView.onTouchEvent(MotionEvent.obtain(50, ts, MotionEvent.ACTION_UP, 0, 0, 0));
    verify(eventDispatcher).dispatchEvent(upEventCaptor.capture());
    verifyNoMoreInteractions(eventDispatcher);

    upEventCaptor.getValue().dispatch(eventEmitterModuleMock);
    verify(eventEmitterModuleMock)
        .receiveTouches(
            eq("topTouchEnd"), upActionTouchesArgCaptor.capture(), any(WritableArray.class));
    verifyNoMoreInteractions(eventEmitterModuleMock);

    assertThat(upActionTouchesArgCaptor.getValue().size()).isEqualTo(1);
    assertThat(upActionTouchesArgCaptor.getValue().getMap(0))
        .isEqualTo(
            SimpleMap.of(
                "pageX",
                0.,
                "pageY",
                0.,
                "locationX",
                0.,
                "locationY",
                0.,
                "target",
                rootViewId,
                "timeStamp",
                (double) ts,
                "identifier",
                0.));

    // Test other action
    reset(eventDispatcher);
    rootView.onTouchEvent(
        MotionEvent.obtain(50, new Date().getTime(), MotionEvent.ACTION_HOVER_MOVE, 0, 0, 0));
    verifyNoMoreInteractions(eventDispatcher);
  }