com.facebook.react.ReactRootView Java Examples

The following examples show how to use com.facebook.react.ReactRootView. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MainActivity.java    From rn-camera-roll with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mReactRootView = new ReactRootView(this);

    mReactInstanceManager = ReactInstanceManager.builder()
            .setApplication(getApplication())
            .setBundleAssetName("index.android.bundle")
            .setJSMainModuleName("index.android")
            .addPackage(new MainReactPackage())

            // Add Camera Roll for android
            .addPackage(new CameraRollPackage())
            .setUseDeveloperSupport(BuildConfig.DEBUG)
            .setInitialLifecycleState(LifecycleState.RESUMED)
            .build();

    mReactRootView.startReactApplication(mReactInstanceManager, "example", null);

    setContentView(mReactRootView);
}
 
Example #2
Source File: QtalkServiceExternalRNActivity.java    From imsdk-android with MIT License 6 votes vote down vote up
private void bindView() {
        try {
            qtNewActionBar = (QtNewActionBar) this.findViewById(R.id.my_action_bar);
            setNewActionBar(qtNewActionBar);
            boolean isShow = Boolean.parseBoolean(getIntent().getStringExtra("showNativeNav"));
            if (isShow) {
                String title = getIntent().getStringExtra("navTitle");
                setActionBarTitle(title);
                setActionBarVisibility(true);
            } else {
                setActionBarVisibility(false);
            }
//        mReactRootView = new ReactRootView(this);
            mReactRootView = (ReactRootView) findViewById(R.id.mReactRootView);
            startRNApplicationWithBundle(getExtendBundle());
//        setContentView(mReactRootView);
        }catch (Exception e){
            Logger.i("打开外部RN应用出现不可预知错误:"+e.getMessage());
        }
    }
 
Example #3
Source File: ReactTextTest.java    From react-native-GPay with MIT License 6 votes vote down vote up
@Test
public void testTextDecorationLineLineThroughApplied() {
  UIManagerModule uiManager = getUIManagerModule();

  ReactRootView rootView = createText(
      uiManager,
      JavaOnlyMap.of(ViewProps.TEXT_DECORATION_LINE, "line-through"),
      JavaOnlyMap.of(ReactRawTextShadowNode.PROP_TEXT, "test text"));

  TextView textView = (TextView) rootView.getChildAt(0);
  Spanned text = (Spanned) textView.getText();
  UnderlineSpan[] underlineSpans =
      text.getSpans(0, text.length(), UnderlineSpan.class);
  StrikethroughSpan strikeThroughSpan =
      getSingleSpan(textView, StrikethroughSpan.class);
  assertThat(underlineSpans).hasSize(0);
  assertThat(strikeThroughSpan instanceof StrikethroughSpan).isTrue();
}
 
Example #4
Source File: RNCustomKeyboardKitModule.java    From react-native-custom-keyboard-kit with MIT License 6 votes vote down vote up
private View createCustomKeyboardKit(Activity activity, int tag, String type) {
  RelativeLayout layout = new RelativeLayout(activity);
  rootView = new ReactRootView(this.getReactApplicationContext());
  rootView.setBackgroundColor(Color.WHITE);

  Bundle bundle = new Bundle();
  bundle.putInt("tag", tag);
  bundle.putString("type", type);
  rootView.startReactApplication(
          ((ReactApplication) activity.getApplication()).getReactNativeHost().getReactInstanceManager(),
          "CustomKeyboardKit",
          bundle);

  final float scale = activity.getResources().getDisplayMetrics().density;
  RelativeLayout.LayoutParams lParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, Math.round(216*scale));
  lParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
  layout.addView(rootView, lParams);
  // activity.addContentView(layout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
  return layout;
}
 
Example #5
Source File: ReactRootViewTestCase.java    From react-native-GPay with MIT License 6 votes vote down vote up
@Ignore("t6596940: fix intermittently failing test")
public void testResizeRootView() throws Throwable {
  final ReactRootView rootView = (ReactRootView) getRootView();
  final View childView = rootView.getChildAt(0);

  assertEquals(rootView.getWidth(), childView.getWidth());

  final int newWidth = rootView.getWidth() / 2;

  runTestOnUiThread(
      new Runnable() {
        @Override
        public void run() {
          rootView.setLayoutParams(new FrameLayout.LayoutParams(
                  newWidth,
                  ViewGroup.LayoutParams.MATCH_PARENT));
        }
      });

  getInstrumentation().waitForIdleSync();
  waitForBridgeAndUIIdle();

  assertEquals(newWidth, childView.getWidth());
}
 
Example #6
Source File: CatalystUIManagerTestCase.java    From react-native-GPay with MIT License 6 votes vote down vote up
public void _testCenteredText(String text) {
  ReactRootView rootView = new ReactRootView(getContext());
  int rootTag = uiManager.addRootView(rootView);

  jsModule.renderCenteredTextViewTestApplication(rootTag, text);
  waitForBridgeAndUIIdle();

  TextView textView = getViewByTestId(rootView, "text");

  // text view should be centered
  String msg = "text `" + text + "` is not centered";
  assertTrue(msg, textView.getLeft() > 0.1);
  assertTrue(msg, textView.getTop() > 0.1);
  assertEquals(
      msg,
      (int) Math.ceil((inPixelRounded(200) - textView.getWidth()) * 0.5f),
      textView.getLeft());
  assertEquals(
      msg,
      (int) Math.ceil((inPixelRounded(100) - textView.getHeight()) * 0.5f),
      textView.getTop());
}
 
Example #7
Source File: ReactAppTestActivity.java    From react-native-GPay with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  overridePendingTransition(0, 0);

  // We wrap screenshot layout in another FrameLayout in order to handle custom dimensions of the
  // screenshot view set through {@link #setScreenshotDimensions}
  FrameLayout rootView = new FrameLayout(this);
  setContentView(rootView);

  mScreenshotingFrameLayout = new ScreenshotingFrameLayout(this);
  mScreenshotingFrameLayout.setId(ROOT_VIEW_ID);
  rootView.addView(mScreenshotingFrameLayout);

  mReactRootView = new ReactRootView(this);
  Intent intent = getIntent();
  if (intent != null && intent.getBooleanExtra(EXTRA_IS_FABRIC_TEST, false)) {
    mReactRootView.setIsFabric(true);
  }

  mScreenshotingFrameLayout.addView(mReactRootView);
}
 
Example #8
Source File: ReactTextTest.java    From react-native-GPay with MIT License 6 votes vote down vote up
@Test
public void testFontFamilyBoldItalicStyleApplied() {
  UIManagerModule uiManager = getUIManagerModule();

  ReactRootView rootView = createText(
      uiManager,
      JavaOnlyMap.of(
          ViewProps.FONT_FAMILY, "sans-serif",
          ViewProps.FONT_WEIGHT, "500",
          ViewProps.FONT_STYLE, "italic"),
      JavaOnlyMap.of(ReactRawTextShadowNode.PROP_TEXT, "test text"));

  CustomStyleSpan customStyleSpan =
      getSingleSpan((TextView) rootView.getChildAt(0), CustomStyleSpan.class);
  assertThat(customStyleSpan.getFontFamily()).isEqualTo("sans-serif");
  assertThat(customStyleSpan.getStyle() & Typeface.ITALIC).isNotZero();
  assertThat(customStyleSpan.getWeight() & Typeface.BOLD).isNotZero();
}
 
Example #9
Source File: ReactTextTest.java    From react-native-GPay with MIT License 6 votes vote down vote up
@Test
public void testTextDecorationLineUnderlineApplied() {
  UIManagerModule uiManager = getUIManagerModule();

  ReactRootView rootView = createText(
      uiManager,
      JavaOnlyMap.of(ViewProps.TEXT_DECORATION_LINE, "underline"),
      JavaOnlyMap.of(ReactRawTextShadowNode.PROP_TEXT, "test text"));

  TextView textView = (TextView) rootView.getChildAt(0);
  Spanned text = (Spanned) textView.getText();
  UnderlineSpan underlineSpan = getSingleSpan(textView, UnderlineSpan.class);
  StrikethroughSpan[] strikeThroughSpans =
      text.getSpans(0, text.length(), StrikethroughSpan.class);
  assertThat(underlineSpan instanceof UnderlineSpan).isTrue();
  assertThat(strikeThroughSpans).hasSize(0);
}
 
Example #10
Source File: ReactTextTest.java    From react-native-GPay with MIT License 6 votes vote down vote up
@Test
public void testTextDecorationLineUnderlineLineThroughApplied() {
  UIManagerModule uiManager = getUIManagerModule();

  ReactRootView rootView = createText(
      uiManager,
      JavaOnlyMap.of(ViewProps.TEXT_DECORATION_LINE, "underline line-through"),
      JavaOnlyMap.of(ReactRawTextShadowNode.PROP_TEXT, "test text"));

  UnderlineSpan underlineSpan =
      getSingleSpan((TextView) rootView.getChildAt(0), UnderlineSpan.class);
  StrikethroughSpan strikeThroughSpan =
      getSingleSpan((TextView) rootView.getChildAt(0), StrikethroughSpan.class);
  assertThat(underlineSpan instanceof UnderlineSpan).isTrue();
  assertThat(strikeThroughSpan instanceof StrikethroughSpan).isTrue();
}
 
Example #11
Source File: FabricUIManagerTest.java    From react-native-GPay with MIT License 6 votes vote down vote up
@Test
public void testSealReactShadowNode() {
  ReactRootView rootView =
    new ReactRootView(RuntimeEnvironment.application.getApplicationContext());
  int rootTag = mFabricUIManager.addRootView(rootView);
  String viewClass = ReactViewManager.REACT_CLASS;

  ReactShadowNode container = mFabricUIManager.createNode(6, viewClass, rootTag, null, randomInstanceHandle());
  List<ReactShadowNode> childSet = mFabricUIManager.createChildSet(rootTag);
  mFabricUIManager.appendChildToSet(childSet, container);

  assertThat(container.isSealed()).isFalse();

  mFabricUIManager.completeRoot(rootTag, childSet);

  assertThat(container.isSealed()).isTrue();
}
 
Example #12
Source File: FabricUIManagerTest.java    From react-native-GPay with MIT License 6 votes vote down vote up
/**
 * Tests that cloned text nodes will not share measure functions
 */
@Test
public void testTextMutableClone() {
  ReactRootView rootView =
      new ReactRootView(RuntimeEnvironment.application.getApplicationContext());
  int rootTag = mFabricUIManager.addRootView(rootView);
  ReactShadowNode text =
      mFabricUIManager.createNode(0, ReactTextViewManager.REACT_CLASS, rootTag, null, randomInstanceHandle());
  assertThat(text.isMeasureDefined()).isTrue();

  ReactShadowNode textCopy = text.mutableCopy(randomInstanceHandle());
  assertThat(textCopy.isMeasureDefined()).isTrue();

  textCopy.setStyleWidth(200);
  text.onBeforeLayout();
  text.calculateLayout();
  textCopy.onBeforeLayout();
  textCopy.calculateLayout();

  assertThat(text.getLayoutWidth()).isNotEqualTo(textCopy.getLayoutWidth());
}
 
Example #13
Source File: ReactNativeIntents.java    From native-navigation with MIT License 6 votes vote down vote up
static Bundle getSharedElementOptionsBundle(
        Activity activity, Intent intent, @Nullable ReadableMap options) {
  ViewGroup transitionGroup = null;
  if (activity instanceof ReactInterface && options != null &&
          options.hasKey(SHARED_ELEMENT_TRANSITION_GROUP_OPTION)) {
    ReactRootView reactRootView = ((ReactInterface) activity).getReactRootView();
    transitionGroup = ViewUtils.findViewGroupWithTag(
            reactRootView,
            R.id.react_shared_element_group_id,
            options.getString(SHARED_ELEMENT_TRANSITION_GROUP_OPTION));
  }

  if (transitionGroup == null) {
    // Even though there is no transition group, we want the activity options to include a scene
    // transition so that we can postpone the enter transition.
    //noinspection unchecked
    return ActivityOptionsCompat.makeSceneTransitionAnimation(activity).toBundle();
  } else {
    ReactNativeUtils.setIsSharedElementTransition(intent);
    return AutoSharedElementCallback.getActivityOptionsBundle(activity, transitionGroup);
  }
}
 
Example #14
Source File: MainActivity.java    From react-native-android-audio-streaming-aac with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mReactRootView = new ReactRootView(this);

    mReactInstanceManager = ReactInstanceManager.builder()
            .setApplication(getApplication())
            .setBundleAssetName("index.android.bundle")
            .setJSMainModuleName("index.android")
            .addPackage(new MainReactPackage())
            .addPackage(new AACStreamingPackage(MainActivity.class))      // <------- add package
            .setUseDeveloperSupport(BuildConfig.DEBUG)
            .setInitialLifecycleState(LifecycleState.RESUMED)
            .build();

    mReactRootView.startReactApplication(mReactInstanceManager, "example", null);

    setContentView(mReactRootView);
}
 
Example #15
Source File: PreReactRootViewLoader.java    From vinci with Apache License 2.0 5 votes vote down vote up
public static void removeView(String componentName){
    ReactRootView reactRootView = CACHE.get(componentName);
    ViewGroup parentView = (ViewGroup) reactRootView.getParent();
    if(parentView != null){
        parentView.removeView(reactRootView);
    }
}
 
Example #16
Source File: ReactPreLoader.java    From react-native-preloader with Apache License 2.0 5 votes vote down vote up
/**
 * Remove {@link ReactRootView} from parent.
 */
public static void onDestroy(ReactInfo reactInfo) {
    try {
        ReactRootView rootView = getRootView(reactInfo);
        ViewGroup parent = (ViewGroup) rootView.getParent();
        if (parent != null) {
            parent.removeView(rootView);
        }
    } catch (Throwable e) {
        Log.e(TAG, e.getMessage());
    }
}
 
Example #17
Source File: UIManagerModuleTest.java    From react-native-GPay with MIT License 5 votes vote down vote up
/**
 * Assuming no other views have been created, the root view will have tag 1, Text tag 2, and
 * RawText tag 3.
 */
private ViewGroup createSimpleTextHierarchy(UIManagerModule uiManager, String text) {
  ReactRootView rootView =
      new ReactRootView(RuntimeEnvironment.application.getApplicationContext());
  int rootTag = uiManager.addRootView(rootView);
  int textTag = rootTag + 1;
  int rawTextTag = textTag + 1;

  uiManager.createView(
      textTag,
      ReactTextViewManager.REACT_CLASS,
      rootTag,
      JavaOnlyMap.of("collapsable", false));
  uiManager.createView(
      rawTextTag,
      ReactRawTextManager.REACT_CLASS,
      rootTag,
      JavaOnlyMap.of(ReactRawTextShadowNode.PROP_TEXT, text, "collapsable", false));

  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();
  executePendingFrameCallbacks();

  return rootView;
}
 
Example #18
Source File: FabricUIManagerTest.java    From react-native-GPay with MIT License 5 votes vote down vote up
/**
 * Verifies that the reconciliation phase will always set the originalNode field of every node in
 * the tree to null once completeRoot has finished to prevent memory leaks.
 */
@Test
public void testRemoveOriginalNodeReferences() {
  ReactRootView rootView =
      new ReactRootView(RuntimeEnvironment.application.getApplicationContext());
  int rootTag = mFabricUIManager.addRootView(rootView);
  String viewClass = ReactViewManager.REACT_CLASS;

  ReactShadowNode aa = mFabricUIManager.createNode(2, viewClass, rootTag, null, randomInstanceHandle());
  ReactShadowNode a = mFabricUIManager.createNode(3, viewClass, rootTag, null, randomInstanceHandle());
  mFabricUIManager.appendChild(a, aa);
  ReactShadowNode bb = mFabricUIManager.createNode(4, viewClass, rootTag, null, randomInstanceHandle());
  ReactShadowNode b = mFabricUIManager.createNode(5, viewClass, rootTag, null, randomInstanceHandle());
  mFabricUIManager.appendChild(b, bb);
  ReactShadowNode container = mFabricUIManager.createNode(6, viewClass, rootTag, null, randomInstanceHandle());
  mFabricUIManager.appendChild(container, a);
  mFabricUIManager.appendChild(container, b);
  List<ReactShadowNode> childSet = mFabricUIManager.createChildSet(rootTag);
  mFabricUIManager.appendChildToSet(childSet, container);
  mFabricUIManager.completeRoot(rootTag, childSet);

  ReactShadowNode aaClone = mFabricUIManager.cloneNodeWithNewProps(aa, null);
  ReactShadowNode aClone = mFabricUIManager.cloneNodeWithNewChildren(a);
  mFabricUIManager.appendChild(aClone, aaClone);
  ReactShadowNode containerClone = mFabricUIManager.cloneNodeWithNewChildren(container);
  mFabricUIManager.appendChild(containerClone, b);
  mFabricUIManager.appendChild(containerClone, aClone);
  List<ReactShadowNode> childSet2 = mFabricUIManager.createChildSet(rootTag);
  mFabricUIManager.appendChildToSet(childSet2, containerClone);
  mFabricUIManager.completeRoot(rootTag, childSet2);

  ReactShadowNode[] nodes =
      new ReactShadowNode[] {aa, a, bb, b, container, aaClone, aClone, containerClone};

  for (ReactShadowNode node : nodes) {
    assertThat(node.getOriginalReactShadowNode()).isNull();
  }
}
 
Example #19
Source File: RNFoundFragment.java    From imsdk-android with MIT License 5 votes vote down vote up
@Override
public void onAttach(Context context) {
    super.onAttach(context);
    mReactRootView = new ReactRootView(context);
    activity = getActivity();
    mReactInstanceManager = QtalkServiceRNViewInstanceManager.getInstanceManager(activity);


}
 
Example #20
Source File: ReactPreLoader.java    From react-native-preloader with Apache License 2.0 5 votes vote down vote up
/**
 * Pre-load {@link ReactRootView} to local {@link Map}, you may want to
 * load it in previous activity.
 */
public static void init(Activity activity, ReactInfo reactInfo) {
    if (CACHE_VIEW_MAP.get(reactInfo.getMainComponentName()) != null) {
        return;
    }
    ReactRootView rootView = new ReactRootView(new MutableContextWrapper(activity));
    rootView.startReactApplication(
            ((ReactApplication) activity.getApplication()).getReactNativeHost().getReactInstanceManager(),
            reactInfo.getMainComponentName(),
            reactInfo.getLaunchOptions());
    CACHE_VIEW_MAP.put(reactInfo.getMainComponentName(), rootView);
}
 
Example #21
Source File: FabricUIManagerTest.java    From react-native-GPay with MIT License 5 votes vote down vote up
@Test
public void testCompleteRoot() {
  ReactRootView rootView =
      new ReactRootView(RuntimeEnvironment.application.getApplicationContext());
  int rootTag = mFabricUIManager.addRootView(rootView);
  List<ReactShadowNode> children = mFabricUIManager.createChildSet(rootTag);

  mFabricUIManager.completeRoot(rootTag, children);
}
 
Example #22
Source File: FabricUIManagerTest.java    From react-native-GPay with MIT License 5 votes vote down vote up
private int createAndRenderRootView() {
  ReactRootView rootView =
      new ReactRootView(RuntimeEnvironment.application.getApplicationContext());
  int rootTag = mFabricUIManager.addRootView(rootView);
  int reactTag = mNextReactTag++;
  String viewClass = ReactViewManager.REACT_CLASS;
  ReactShadowNode node =
      mFabricUIManager.createNode(reactTag, viewClass, rootTag, null, randomInstanceHandle());

  List<ReactShadowNode> childSet = mFabricUIManager.createChildSet(rootTag);
  mFabricUIManager.appendChildToSet(childSet, node);
  mFabricUIManager.completeRoot(rootTag, childSet);

  return rootTag;
}
 
Example #23
Source File: FabricUIManagerTest.java    From react-native-GPay with MIT License 5 votes vote down vote up
@Test
public void testCreateNode() {
  ReactRootView rootView =
      new ReactRootView(RuntimeEnvironment.application.getApplicationContext());
  int rootTag = mFabricUIManager.addRootView(rootView);
  int reactTag = mNextReactTag++;
  String viewClass = ReactViewManager.REACT_CLASS;
  ReactShadowNode node =
      mFabricUIManager.createNode(reactTag, viewClass, rootTag, null, randomInstanceHandle());

  assertThat(reactTag).isEqualTo(node.getReactTag());
  assertThat(viewClass).isEqualTo(node.getViewClass());
  assertThat(rootTag).isEqualTo(rootTag);
}
 
Example #24
Source File: ReactTextTest.java    From react-native-GPay with MIT License 5 votes vote down vote up
private ReactRootView createText(
    UIManagerModule uiManager,
    JavaOnlyMap textProps,
    JavaOnlyMap rawTextProps) {
  ReactRootView rootView = new ReactRootView(RuntimeEnvironment.application);
  int rootTag = uiManager.addRootView(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();
  executePendingFrameCallbacks();
  return rootView;
}
 
Example #25
Source File: MyFragment.java    From react-native-aztec with GNU General Public License v2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (mReactInstanceManager == null) {
        try {
            mReactInstanceManager = ((SampleRNBaseActivity) getActivity()).getReactInstanceManager();
        } catch (ClassCastException e) {
            throw new ClassCastException(getActivity().toString() + " must extends SampleRNBaseActivity");
        }
    }

    ReactRootView reactRootView = new ReactRootView(getContext());
    reactRootView.startReactApplication(mReactInstanceManager, "example", null);
    return reactRootView;
}
 
Example #26
Source File: ReactTextTest.java    From react-native-GPay with MIT License 5 votes vote down vote up
@Test
public void testTextTransformCapitalizeApplied() {
  UIManagerModule uiManager = getUIManagerModule();

  String testTextEntered = ".aa\tbb\t\tcc  dd EE \r\nZZ I like to eat apples. \n中文éé 我喜欢吃苹果。awdawd   ";
  String testTextTransformed = ".Aa\tBb\t\tCc  Dd Ee \r\nZz I Like To Eat Apples. \n中文Éé 我喜欢吃苹果。Awdawd   ";

  ReactRootView rootView = createText(
      uiManager,
      JavaOnlyMap.of("textTransform", "capitalize"),
      JavaOnlyMap.of(ReactRawTextShadowNode.PROP_TEXT, testTextEntered));

  TextView textView = (TextView) rootView.getChildAt(0);
  assertThat(textView.getText().toString()).isEqualTo(testTextTransformed);
}
 
Example #27
Source File: ReactTextTest.java    From react-native-GPay with MIT License 5 votes vote down vote up
@Test
public void testTextTransformLowercaseApplied() {
  UIManagerModule uiManager = getUIManagerModule();

  String testTextEntered = ".aa\tbb\t\tcc  dd EE \r\nZZ I like to eat apples. \n中文éé 我喜欢吃苹果。awdawd   ";
  String testTextTransformed = ".aa\tbb\t\tcc  dd ee \r\nzz i like to eat apples. \n中文éé 我喜欢吃苹果。awdawd   ";

  ReactRootView rootView = createText(
      uiManager,
      JavaOnlyMap.of("textTransform", "lowercase"),
      JavaOnlyMap.of(ReactRawTextShadowNode.PROP_TEXT, testTextEntered));

  TextView textView = (TextView) rootView.getChildAt(0);
  assertThat(textView.getText().toString()).isEqualTo(testTextTransformed);
}
 
Example #28
Source File: ReactTextTest.java    From react-native-GPay with MIT License 5 votes vote down vote up
@Test
public void testTextTransformUppercaseApplied() {
  UIManagerModule uiManager = getUIManagerModule();

  String testTextEntered = ".aa\tbb\t\tcc  dd EE \r\nZZ I like to eat apples. \n中文éé 我喜欢吃苹果。awdawd   ";
  String testTextTransformed = ".AA\tBB\t\tCC  DD EE \r\nZZ I LIKE TO EAT APPLES. \n中文ÉÉ 我喜欢吃苹果。AWDAWD   ";

  ReactRootView rootView = createText(
      uiManager,
      JavaOnlyMap.of("textTransform", "uppercase"),
      JavaOnlyMap.of(ReactRawTextShadowNode.PROP_TEXT, testTextEntered));

  TextView textView = (TextView) rootView.getChildAt(0);
  assertThat(textView.getText().toString()).isEqualTo(testTextTransformed);
}
 
Example #29
Source File: ReactTextTest.java    From react-native-GPay with MIT License 5 votes vote down vote up
@Test
public void testTextTransformNoneApplied() {
  UIManagerModule uiManager = getUIManagerModule();

  String testTextEntered = ".aa\tbb\t\tcc  dd EE \r\nZZ I like to eat apples. \n中文éé 我喜欢吃苹果。awdawd   ";
  String testTextTransformed = testTextEntered;

  ReactRootView rootView = createText(
      uiManager,
      JavaOnlyMap.of("textTransform", "none"),
      JavaOnlyMap.of(ReactRawTextShadowNode.PROP_TEXT, testTextEntered));

  TextView textView = (TextView) rootView.getChildAt(0);
  assertThat(textView.getText().toString()).isEqualTo(testTextTransformed);
}
 
Example #30
Source File: UIManagerModuleTest.java    From react-native-GPay with MIT License 5 votes vote down vote up
public TestMoveDeleteHierarchy(ReactRootView nativeRootView, int rootViewTag) {
  this.nativeRootView = nativeRootView;
  rootView = rootViewTag;
  view0 = rootView + 1;
  viewWithChildren1 = rootView + 2;
  view2 = rootView + 3;
  view3 = rootView + 4;
  childView0 = rootView + 5;
  childView1 = rootView + 6;
}