@Test public void testUpdateSimpleHierarchy() { UIManagerModule uiManager = getUIManagerModule(); ViewGroup rootView = createSimpleTextHierarchy(uiManager, "Some text"); TextView textView = (TextView) rootView.getChildAt(0); int rawTextTag = 3; uiManager.updateView( rawTextTag, ReactRawTextManager.REACT_CLASS, JavaOnlyMap.of(ReactTextShadowNode.PROP_TEXT, "New text")); uiManager.onBatchComplete(); executePendingFrameCallbacks(); assertThat(textView.getText().toString()).isEqualTo("New text"); }
@Test public void testUpdateSimpleHierarchy() { UIManagerModule uiManager = getUIManagerModule(); ViewGroup rootView = createSimpleTextHierarchy(uiManager, "Some text"); TextView textView = (TextView) rootView.getChildAt(0); int rawTextTag = 3; uiManager.updateView( rawTextTag, ReactRawTextManager.REACT_CLASS, JavaOnlyMap.of(ReactTextShadowNode.PROP_TEXT, "New text")); uiManager.onBatchComplete(); executePendingChoreographerCallbacks(); assertThat(textView.getText().toString()).isEqualTo("New text"); }
/** * 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.addMeasuredRootView(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(ReactTextShadowNode.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; }
/** * 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.addMeasuredRootView(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(ReactTextShadowNode.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(); executePendingChoreographerCallbacks(); return rootView; }