LayoutState.createAndMeasureTreeForComponent(c, this, widthSpec, heightSpec);
private static InternalNode acquireInternalNode() { final ComponentContext context = new ComponentContext(RuntimeEnvironment.application); return createAndMeasureTreeForComponent( context, Column.create(context).build(), makeSizeSpec(0, UNSPECIFIED), makeSizeSpec(0, UNSPECIFIED)); }
private static InternalNode acquireInternalNodeWithLogger(ComponentsLogger logger) { final ComponentContext context = new ComponentContext(RuntimeEnvironment.application, "TEST", logger); return createAndMeasureTreeForComponent( context, Column.create(context).build(), makeSizeSpec(0, UNSPECIFIED), makeSizeSpec(0, UNSPECIFIED)); }
@Before public void setup() { final ComponentContext context = new ComponentContext(RuntimeEnvironment.application); mInternalNode = createAndMeasureTreeForComponent( context, Column.create(context).build(), makeSizeSpec(0, UNSPECIFIED), makeSizeSpec(0, UNSPECIFIED)); }
when(LayoutState.createAndMeasureTreeForComponent(mContext, component, holder, 100, 100, null)) .thenReturn(resolved); LayoutState.createAndMeasureTreeForComponent(mContext, component, holder, 100, 100, null); LayoutState.createAndMeasureTreeForComponent(mContext, component, holder, 100, 100, null);
when(LayoutState.createAndMeasureTreeForComponent(mContext, component, holder, 100, 100, null)) .thenReturn(resolved); LayoutState.createAndMeasureTreeForComponent(mContext, component, holder, 100, 100, null); LayoutState.createAndMeasureTreeForComponent(mContext, component, holder, 100, 100, null);
final InternalNode root = layoutCreatedInWillRender == null ? createAndMeasureTreeForComponent( c, component,
@Test public void testMeasure() { final int width = 50; final int height = 30; final ComponentContext c = new ComponentContext(application); final Component component = new InlineLayoutSpec() { @Override protected Component onCreateLayout(final ComponentContext c) { return create(c) .child(TestDrawableComponent.create(c).measuredWidth(width).measuredHeight(height)) .build(); } }; final InternalNode node = createAndMeasureTreeForComponent( c, component, makeSizeSpec(width, AT_MOST), makeSizeSpec(height, AT_MOST)); assertThat(node.getWidth()).isEqualTo(width); assertThat(node.getHeight()).isEqualTo(height); assertThat(node.getChildCount()).isEqualTo(1); assertThat(((InternalNode) node.getChildAt(0)).getWidth()).isEqualTo(width); assertThat(((InternalNode) node.getChildAt(0)).getHeight()).isEqualTo(height); }
@Before public void setup() { final ComponentContext context = new ComponentContext(RuntimeEnvironment.application); mInternalNode = createAndMeasureTreeForComponent( context, Column.create(context).build(), makeSizeSpec(0, UNSPECIFIED), makeSizeSpec(0, UNSPECIFIED)); mInternalNode.touchHandler(new EventHandler(null, 1)); }
@Test public void testLayoutOutputForRootNestedTreeComponentWithPercentPadding() { final Component component = new InlineLayoutSpec() { @Override protected Component onCreateLayout(final ComponentContext c) { return create(c) .alignItems(FLEX_START) .widthPx(50) .heightPx(50) .child( TestSizeDependentComponent.create(c) .setFixSizes(true) .paddingPercent(ALL, 10) .backgroundColor(0xFFFF0000)) .build(); } }; final InternalNode root = createAndMeasureTreeForComponent( new ComponentContext(application), component, makeSizeSpec(0, UNSPECIFIED), makeSizeSpec(0, UNSPECIFIED)); assertThat(root.getChildAt(0).getNestedTree().getPaddingLeft()).isEqualTo(5); assertThat(root.getChildAt(0).getNestedTree().getPaddingTop()).isEqualTo(5); assertThat(root.getChildAt(0).getNestedTree().getPaddingRight()).isEqualTo(5); assertThat(root.getChildAt(0).getNestedTree().getPaddingBottom()).isEqualTo(5); }
@VisibleForTesting static InternalNode createAndMeasureTreeForComponent( ComponentContext c, Component component, InternalNode nestedTreeHolder, // This will be set only if we are resolving a nested tree. int widthSpec, int heightSpec, DiffNode diffTreeRoot) { component.updateInternalChildState(c); if (ComponentsConfiguration.isDebugModeEnabled) { DebugComponent.applyOverrides(c, component); } c = component.getScopedContext(); final boolean isTest = "robolectric".equals(Build.FINGERPRINT); // Copy the context so that it can have its own set of tree props. // Robolectric tests keep the context so that tree props can be set externally. if (!isTest) { c = c.makeNewCopy(); } final boolean hasNestedTreeHolder = nestedTreeHolder != null; if (hasNestedTreeHolder) { c.setTreeProps(nestedTreeHolder.getPendingTreeProps()); } // Account for the size specs in ComponentContext in case the tree is a NestedTree.
createAndMeasureTreeForComponent( context, component,