com.facebook.react.views.text.ReactTextViewManager Java Examples

The following examples show how to use com.facebook.react.views.text.ReactTextViewManager. 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: 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 #2
Source File: MainReactPackage.java    From react-native-gcm-android with MIT License 6 votes vote down vote up
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
    return Arrays.<ViewManager>asList(
            new ReactDrawerLayoutManager(),
            new ReactHorizontalScrollViewManager(),
            new ReactImageManager(),
            new ReactProgressBarViewManager(),
            new ReactRawTextManager(),
            new ReactScrollViewManager(),
            new ReactSwitchManager(),
            new ReactTextInputManager(),
            new ReactTextViewManager(),
            new ReactToolbarManager(),
            new ReactViewManager(),
            new ReactViewPagerManager(),
            new ReactTextInlineImageViewManager(),
            new ReactVirtualTextViewManager(),
            new SwipeRefreshLayoutManager(),
            new ReactWebViewManager());
}
 
Example #3
Source File: MainReactPackage.java    From react-native-GPay with MIT License 5 votes vote down vote up
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
  List<ViewManager> viewManagers = new ArrayList<>();

  viewManagers.add(ARTRenderableViewManager.createARTGroupViewManager());
  viewManagers.add(ARTRenderableViewManager.createARTShapeViewManager());
  viewManagers.add(ARTRenderableViewManager.createARTTextViewManager());
  viewManagers.add(new ReactCheckBoxManager());
  viewManagers.add(new ReactDialogPickerManager());
  viewManagers.add(new ReactDrawerLayoutManager());
  viewManagers.add(new ReactDropdownPickerManager());
  viewManagers.add(new ReactHorizontalScrollViewManager());
  viewManagers.add(new ReactHorizontalScrollContainerViewManager());
  viewManagers.add(new ReactProgressBarViewManager());
  viewManagers.add(new ReactScrollViewManager());
  viewManagers.add(new ReactSliderManager());
  viewManagers.add(new ReactSwitchManager());
  viewManagers.add(new ReactToolbarManager());
  viewManagers.add(new ReactWebViewManager());
  viewManagers.add(new SwipeRefreshLayoutManager());

  // Native equivalents
  viewManagers.add(new ARTSurfaceViewManager());
  viewManagers.add(new FrescoBasedReactTextInlineImageViewManager());
  viewManagers.add(new ReactImageManager());
  viewManagers.add(new ReactModalHostManager());
  viewManagers.add(new ReactRawTextManager());
  viewManagers.add(new ReactTextInputManager());
  viewManagers.add(new ReactTextViewManager());
  viewManagers.add(new ReactViewManager());
  viewManagers.add(new ReactViewPagerManager());
  viewManagers.add(new ReactVirtualTextViewManager());

  return viewManagers;
}
 
Example #4
Source File: CatalystUIManagerTestCase.java    From react-native-GPay with MIT License 5 votes vote down vote up
@Override
protected void setUp() throws Exception {
  super.setUp();

  List<ViewManager> viewManagers = Arrays.<ViewManager>asList(
      new ReactViewManager(),
      new ReactTextViewManager(),
      new ReactRawTextManager());
  uiManager =
      new UIManagerModule(getContext(), viewManagers, 0);
  UiThreadUtil.runOnUiThread(new Runnable() {
    @Override
    public void run() {
      uiManager.onHostResume();
    }
  });
  waitForIdleSync();

  jsModule = ReactTestHelper.catalystInstanceBuilder(this)
      .addNativeModule(uiManager)
      .addNativeModule(new AndroidInfoModule(getContext()))
      .addNativeModule(new DeviceInfoModule(getContext()))
      .addNativeModule(new AppStateModule(getContext()))
      .addNativeModule(new FakeWebSocketModule())
      .build()
      .getJSModule(UIManagerTestModule.class);
}
 
Example #5
Source File: FabricUIManagerTest.java    From react-native-GPay with MIT License 5 votes vote down vote up
@Before
public void setUp() throws Exception {
  mNextReactTag = 2;
  ReactApplicationContext reactContext = new ReactApplicationContext(RuntimeEnvironment.application);
  reactContext.initializeWithInstance(ReactTestHelper.createMockCatalystInstance());
  mThemedReactContext = new ThemedReactContext(reactContext, reactContext);

  List<ViewManager> viewManagers =
      Arrays.<ViewManager>asList(
          new ReactViewManager(), new ReactTextViewManager(), new ReactRawTextManager());
  ViewManagerRegistry viewManagerRegistry = new ViewManagerRegistry(viewManagers);
  JavaScriptContextHolder jsContext = mock(JavaScriptContextHolder.class);
  EventDispatcher eventDispatcher = mock(EventDispatcher.class);
  mFabricUIManager = new FabricUIManager(reactContext, viewManagerRegistry, jsContext, eventDispatcher);
}
 
Example #6
Source File: UIManagerModuleTest.java    From react-native-GPay with MIT License 5 votes vote down vote up
@Test
public void testMoveAndAddViews() {
  UIManagerModule uiManager = getUIManagerModule();
  TestMoveDeleteHierarchy hierarchy = createMoveDeleteHierarchy(uiManager);

  int textViewTag = 1000;
  uiManager.createView(
      textViewTag,
      ReactTextViewManager.REACT_CLASS,
      hierarchy.rootView,
      JavaOnlyMap.of("collapsable", false));

  View expectedViewAt0 = hierarchy.nativeRootView.getChildAt(0);
  View expectedViewAt1 = hierarchy.nativeRootView.getChildAt(3);
  View expectedViewAt3 = hierarchy.nativeRootView.getChildAt(1);
  View expectedViewAt4 = hierarchy.nativeRootView.getChildAt(2);

  uiManager.manageChildren(
      hierarchy.rootView,
      JavaOnlyArray.of(1, 2, 3),
      JavaOnlyArray.of(3, 4, 1),
      JavaOnlyArray.of(textViewTag),
      JavaOnlyArray.of(2),
      null);

  uiManager.onBatchComplete();
  executePendingFrameCallbacks();

  assertThat(hierarchy.nativeRootView.getChildCount()).isEqualTo(5);
  assertThat(hierarchy.nativeRootView.getChildAt(0)).isEqualTo(expectedViewAt0);
  assertThat(hierarchy.nativeRootView.getChildAt(1)).isEqualTo(expectedViewAt1);
  assertThat(hierarchy.nativeRootView.getChildAt(3)).isEqualTo(expectedViewAt3);
  assertThat(hierarchy.nativeRootView.getChildAt(4)).isEqualTo(expectedViewAt4);
}
 
Example #7
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 #8
Source File: UIManagerModuleTest.java    From react-native-GPay with MIT License 5 votes vote down vote up
private UIManagerModule getUIManagerModule() {
  List<ViewManager> viewManagers = Arrays.<ViewManager>asList(
      new ReactViewManager(),
      new ReactTextViewManager(),
      new ReactRawTextManager());
  UIManagerModule uiManagerModule =
      new UIManagerModule(mReactContext, viewManagers, 0);
  uiManagerModule.onHostResume();
  return uiManagerModule;
}
 
Example #9
Source File: UIManagerModuleTest.java    From react-native-GPay with MIT License 4 votes vote down vote up
/**
 * Verifies removeSubviewsFromContainerWithID works by adding subviews, removing them, and
 * checking that the final number of children is correct.
 */
@Test
public void testRemoveSubviewsFromContainerWithID() {
  UIManagerModule uiManager = getUIManagerModule();
  ReactRootView rootView =
      new ReactRootView(RuntimeEnvironment.application.getApplicationContext());
  int rootTag = uiManager.addRootView(rootView);

  final int containerTag = rootTag + 1;
  final int containerSiblingTag = containerTag + 1;

  uiManager.createView(
      containerTag,
      ReactViewManager.REACT_CLASS,
      rootTag,
      JavaOnlyMap.of("collapsable", false));
  uiManager.createView(
      containerSiblingTag,
      ReactViewManager.REACT_CLASS,
      rootTag,
      JavaOnlyMap.of("collapsable", false));
  addChild(uiManager, rootTag, containerTag, 0);
  addChild(uiManager, rootTag, containerSiblingTag, 1);

  uiManager.createView(
      containerTag + 2,
      ReactTextViewManager.REACT_CLASS,
      rootTag,
      JavaOnlyMap.of("collapsable", false));
  uiManager.createView(
      containerTag + 3,
      ReactTextViewManager.REACT_CLASS,
      rootTag,
      JavaOnlyMap.of("collapsable", false));
  addChild(uiManager, containerTag, containerTag + 2, 0);
  addChild(uiManager, containerTag, containerTag + 3, 1);

  uiManager.onBatchComplete();
  executePendingFrameCallbacks();

  assertThat(rootView.getChildCount()).isEqualTo(2);
  assertThat(((ViewGroup) rootView.getChildAt(0)).getChildCount()).isEqualTo(2);

  uiManager.removeSubviewsFromContainerWithID(containerTag);

  uiManager.onBatchComplete();
  executePendingFrameCallbacks();

  assertThat(rootView.getChildCount()).isEqualTo(2);
  assertThat(((ViewGroup) rootView.getChildAt(0)).getChildCount()).isEqualTo(0);
}