本文整理汇总了Java中com.facebook.react.ReactRootView.getChildAt方法的典型用法代码示例。如果您正苦于以下问题:Java ReactRootView.getChildAt方法的具体用法?Java ReactRootView.getChildAt怎么用?Java ReactRootView.getChildAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.facebook.react.ReactRootView
的用法示例。
在下文中一共展示了ReactRootView.getChildAt方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testResizeRootView
import com.facebook.react.ReactRootView; //导入方法依赖的package包/类
@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());
}
示例2: testTextDecorationLineUnderlineApplied
import com.facebook.react.ReactRootView; //导入方法依赖的package包/类
@Test
public void testTextDecorationLineUnderlineApplied() {
UIManagerModule uiManager = getUIManagerModule();
ReactRootView rootView = createText(
uiManager,
JavaOnlyMap.of(ViewProps.TEXT_DECORATION_LINE, "underline"),
JavaOnlyMap.of(ReactTextShadowNode.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);
}
示例3: testTextDecorationLineLineThroughApplied
import com.facebook.react.ReactRootView; //导入方法依赖的package包/类
@Test
public void testTextDecorationLineLineThroughApplied() {
UIManagerModule uiManager = getUIManagerModule();
ReactRootView rootView = createText(
uiManager,
JavaOnlyMap.of(ViewProps.TEXT_DECORATION_LINE, "line-through"),
JavaOnlyMap.of(ReactTextShadowNode.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();
}
示例4: testPropsApplied
import com.facebook.react.ReactRootView; //导入方法依赖的package包/类
@Test
public void testPropsApplied() {
UIManagerModule uiManager = getUIManagerModule();
ReactRootView rootView = new ReactRootView(RuntimeEnvironment.application);
rootView.setLayoutParams(new ReactRootView.LayoutParams(100, 100));
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);
}
示例5: testMaxLinesApplied
import com.facebook.react.ReactRootView; //导入方法依赖的package包/类
@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(ReactTextShadowNode.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);
}
示例6: testPropsApplied
import com.facebook.react.ReactRootView; //导入方法依赖的package包/类
@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);
}
示例7: testPropsUpdate
import com.facebook.react.ReactRootView; //导入方法依赖的package包/类
@Test
public void testPropsUpdate() {
UIManagerModule uiManager = getUIManagerModule();
ReactRootView rootView = new ReactRootView(RuntimeEnvironment.application);
rootView.setLayoutParams(new ReactRootView.LayoutParams(100, 100));
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);
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);
}
示例8: testHierarchyWithView
import com.facebook.react.ReactRootView; //导入方法依赖的package包/类
@Test
public void testHierarchyWithView() {
UIManagerModule uiManager = getUIManagerModule();
ReactRootView rootView =
new ReactRootView(RuntimeEnvironment.application.getApplicationContext());
int rootTag = uiManager.addMeasuredRootView(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);
}
示例9: testPropsUpdate
import com.facebook.react.ReactRootView; //导入方法依赖的package包/类
@Test
public void testPropsUpdate() {
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);
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);
}
示例10: testHierarchyWithView
import com.facebook.react.ReactRootView; //导入方法依赖的package包/类
@Test
public void testHierarchyWithView() {
UIManagerModule uiManager = getUIManagerModule();
ReactRootView rootView =
new ReactRootView(RuntimeEnvironment.application.getApplicationContext());
int rootTag = uiManager.addMeasuredRootView(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();
executePendingChoreographerCallbacks();
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);
}