applyDiffNodeToUnchangedNodes(layoutNode.getChildAt(i), diffNode.getChildAt(i));
@Test public void testCachedMeasures() { final Component component1 = new TestLayoutSpec(false); final Component component2 = new TestLayoutSpec(false); LayoutState prevLayoutState = calculateLayoutStateWithDiffing( mContext, component1, SizeSpec.makeSizeSpec(350, SizeSpec.EXACTLY), SizeSpec.makeSizeSpec(200, SizeSpec.EXACTLY), null); // Check diff tree is consistent. DiffNode node = prevLayoutState.getDiffTree(); InternalNode layoutTreeRoot = LayoutState.createTree( component2, mContext); LayoutState.applyDiffNodeToUnchangedNodes(layoutTreeRoot, node); checkAllComponentsHaveMeasureCache(layoutTreeRoot); }
@Test public void testPartiallyCachedMeasures() { final Component component1 = new TestLayoutSpec(false); final Component component2 = new TestLayoutSpec(true); LayoutState prevLayoutState = calculateLayoutStateWithDiffing( mContext, component1, SizeSpec.makeSizeSpec(350, SizeSpec.EXACTLY), SizeSpec.makeSizeSpec(200, SizeSpec.EXACTLY), null); // Check diff tree is consistent. DiffNode node = prevLayoutState.getDiffTree(); InternalNode layoutTreeRoot = LayoutState.createTree( component2, mContext); LayoutState.applyDiffNodeToUnchangedNodes(layoutTreeRoot, node); InternalNode child_1 = (InternalNode) layoutTreeRoot.getChildAt(0); assertCachedMeasurementsDefined(child_1); InternalNode child_2 = (InternalNode) layoutTreeRoot.getChildAt(1); assertCachedMeasurementsNotDefined(child_2); InternalNode child_3 = (InternalNode) child_2.getChildAt(0); assertCachedMeasurementsDefined(child_3); InternalNode child_4 = (InternalNode) layoutTreeRoot.getChildAt(2); assertCachedMeasurementsNotDefined(child_4); }
applyDiffNodeToUnchangedNodes(root, previousDiffTreeRoot);