예제 #1
0
  @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,
        JavaOnlyMap.of(ViewProps.FONT_SIZE, 13.37, ViewProps.HEIGHT, 20.0, "placeholder", hintStr));

    uiManager.manageChildren(
        rootTag, null, null, JavaOnlyArray.of(textInputTag), JavaOnlyArray.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);
  }
  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;
  }