Java Code Examples for com.facebook.react.ReactRootView#getChildAt()
The following examples show how to use
com.facebook.react.ReactRootView#getChildAt() .
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: ReactRootViewTestCase.java From react-native-GPay with MIT License | 6 votes |
@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 2
Source File: ReactTextTest.java From react-native-GPay with MIT License | 6 votes |
@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 3
Source File: ReactTextTest.java From react-native-GPay with MIT License | 6 votes |
@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: TextInputTest.java From react-native-GPay with MIT License | 5 votes |
@Test public void testPropsApplied() { UIManagerModule uiManager = getUIManagerModule(); ReactRootView rootView = new ReactRootView(RuntimeEnvironment.application); rootView.setLayoutParams(new ReactRootView.LayoutParams(100, 100)); int rootTag = uiManager.addRootView(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); }
Example 5
Source File: ReactTextTest.java From react-native-GPay with MIT License | 5 votes |
@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 6
Source File: ReactTextTest.java From react-native-GPay with MIT License | 5 votes |
@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 7
Source File: ReactTextTest.java From react-native-GPay with MIT License | 5 votes |
@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 8
Source File: ReactTextTest.java From react-native-GPay with MIT License | 5 votes |
@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 9
Source File: ReactTextTest.java From react-native-GPay with MIT License | 5 votes |
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) @Test public void testMaxLinesApplied() { UIManagerModule uiManager = getUIManagerModule(); ReactRootView rootView = createText( uiManager, JavaOnlyMap.of(ViewProps.NUMBER_OF_LINES, 2), JavaOnlyMap.of(ReactRawTextShadowNode.PROP_TEXT, "test text")); TextView textView = (TextView) rootView.getChildAt(0); assertThat(textView.getText().toString()).isEqualTo("test text"); assertThat(textView.getMaxLines()).isEqualTo(2); assertThat(textView.getEllipsize()).isEqualTo(TextUtils.TruncateAt.END); }
Example 10
Source File: TextInputTest.java From react-native-GPay with MIT License | 4 votes |
@Test public void testPropsUpdate() { UIManagerModule uiManager = getUIManagerModule(); ReactRootView rootView = new ReactRootView(RuntimeEnvironment.application); rootView.setLayoutParams(new ReactRootView.LayoutParams(100, 100)); int rootTag = uiManager.addRootView(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); final String hintStr2 = "such hint"; uiManager.updateView( textInputTag, ReactTextInputManager.REACT_CLASS, JavaOnlyMap.of( ViewProps.FONT_SIZE, 26.74, ViewProps.HEIGHT, 40.0, "placeholder", hintStr2)); uiManager.onBatchComplete(); executePendingChoreographerCallbacks(); EditText updatedEditText = (EditText) rootView.getChildAt(0); assertThat(updatedEditText.getHint()).isEqualTo(hintStr2); assertThat(updatedEditText.getTextSize()).isEqualTo((float) Math.ceil(26.74f)); assertThat(updatedEditText.getHeight()).isEqualTo(40); }
Example 11
Source File: UIManagerModuleTest.java From react-native-GPay with MIT License | 4 votes |
@Test public void testHierarchyWithView() { UIManagerModule uiManager = getUIManagerModule(); ReactRootView rootView = new ReactRootView(RuntimeEnvironment.application.getApplicationContext()); int rootTag = uiManager.addRootView(rootView); int viewTag = rootTag + 1; int subViewTag = viewTag + 1; uiManager.createView( viewTag, ReactViewManager.REACT_CLASS, rootTag, JavaOnlyMap.of("collapsable", false)); uiManager.createView( subViewTag, ReactViewManager.REACT_CLASS, rootTag, JavaOnlyMap.of("collapsable", false)); uiManager.manageChildren( viewTag, null, null, JavaOnlyArray.of(subViewTag), JavaOnlyArray.of(0), null); uiManager.manageChildren( rootTag, null, null, JavaOnlyArray.of(viewTag), JavaOnlyArray.of(0), null); uiManager.onBatchComplete(); executePendingFrameCallbacks(); assertThat(rootView.getChildCount()).isEqualTo(1); ViewGroup child = (ViewGroup) rootView.getChildAt(0); assertThat(child.getChildCount()).isEqualTo(1); ViewGroup grandchild = (ViewGroup) child.getChildAt(0); assertThat(grandchild).isInstanceOf(ViewGroup.class); assertThat(grandchild.getChildCount()).isEqualTo(0); }