InternalNode newLayoutBuilder(@AttrRes int defStyleAttr, @StyleRes int defStyleRes) { final InternalNode node = ComponentsPools.acquireInternalNode(this); applyStyle(node, defStyleAttr, defStyleRes); return node; }
@Override InternalNode resolveLayout(Component component) { if (component.canResolve()) { return super.resolveLayout(component); } InternalNode node = ComponentsPools.acquireInternalNode(this); node.appendComponent(new TestComponent(component)); return node; }
@Before public void setup() { mInternalNode = ComponentsPools.acquireInternalNode(new ComponentContext(RuntimeEnvironment.application)); }
@Test public void testCreateLayoutAndDontResolveNestedTreeWithLayoutSpecCanMeasure() { Component component = setUpSpyComponentForCreateLayout( false /* isMountSpec */, true /* canMeasure */); component.createLayout(mContext, false); PowerMockito.verifyStatic(); // Calling here to verify static call. ComponentsPools.acquireInternalNode(mContext); verify(component, never()).onCreateLayout( any(ComponentContext.class)); verify(component, never()).onCreateLayoutWithSizeSpec( any(ComponentContext.class), anyInt(), anyInt()); verify(mNode).appendComponent(component); verify(mNode).setMeasureFunction(any(YogaMeasureFunction.class)); verify(component, never()) .onPrepare(any(ComponentContext.class)); }
@Override public InternalNode newLayoutBuilder( Component component, @AttrRes int defStyleAttr, @StyleRes int defStyleRes) { if (component.canResolve()) { return super.newLayoutBuilder(component, defStyleAttr, defStyleRes); } final InternalNode node = ComponentsPools.acquireInternalNode(this); component.updateInternalChildState(this); node.appendComponent(new TestComponent(component)); return node; }
@Before public void setUp() { mDiffNode = mock(DiffNode.class); mNode = mock(InternalNode.class); final YogaNode cssNode = new YogaNode(); cssNode.setData(mNode); mNode.mYogaNode = cssNode; mockStatic(ComponentsPools.class); when(mNode.getLastWidthSpec()).thenReturn(-1); when(mNode.getDiffNode()).thenReturn(mDiffNode); when(mDiffNode.getLastMeasuredWidth()).thenReturn(-1f); when(mDiffNode.getLastMeasuredHeight()).thenReturn(-1f); when(ComponentsPools.acquireInternalNode(any(ComponentContext.class))).thenReturn(mNode); when(ComponentsPools.acquireComponentTreeBuilder( any(ComponentContext.class), any(Component.class))) .thenCallRealMethod(); mockStatic(LayoutState.class); StateHandler stateHandler = mock(StateHandler.class); mContext = spy(new ComponentContext(RuntimeEnvironment.application, stateHandler)); mNestedTreeWidthSpec = SizeSpec.makeSizeSpec(400, SizeSpec.EXACTLY); mNestedTreeHeightSpec = SizeSpec.makeSizeSpec(200, SizeSpec.EXACTLY); }
@Test(expected=IllegalStateException.class) public void testNodeWithChildren() { assertDefaultValues(mInternalNode); mInternalNode.addChildAt( ComponentsPools.acquireInternalNode(new ComponentContext(RuntimeEnvironment.application)), 0); mInternalNode.release(); } }
@Test(expected=IllegalStateException.class) public void testAttachedNode() { assertDefaultValues(mInternalNode); InternalNode parent = ComponentsPools.acquireInternalNode(new ComponentContext(RuntimeEnvironment.application)); parent.addChildAt(mInternalNode, 0); mInternalNode.release(); }
try { if (deferNestedTreeResolution) { node = ComponentsPools.acquireInternalNode(context); node.markIsNestedTreeHolder(context.getTreeProps()); } else if (component.canResolve()) {