gpt4 book ai didi

com.facebook.yoga.YogaMeasureOutput类的使用及代码示例

转载 作者:知者 更新时间:2024-03-14 16:39:31 27 4
gpt4 key购买 nike

本文整理了Java中com.facebook.yoga.YogaMeasureOutput类的一些代码示例,展示了YogaMeasureOutput类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YogaMeasureOutput类的具体详情如下:
包路径:com.facebook.yoga.YogaMeasureOutput
类名称:YogaMeasureOutput

YogaMeasureOutput介绍

[英]Helpers for building measure output value.
[中]建筑的助手可以测量产值。

代码示例

代码示例来源:origin: facebook/litho

@Test
public void testLayoutSpecMeasureResolveNestedTree() {
 Component component = setUpSpyComponentForCreateLayout(
   false /* isMountSpec */, true /* canMeasure */);
 YogaMeasureFunction measureFunction = getMeasureFunction(component);
 final int nestedTreeWidth = 20;
 final int nestedTreeHeight = 25;
 InternalNode nestedTree = mock(InternalNode.class);
 when(nestedTree.getWidth()).thenReturn(nestedTreeWidth);
 when(nestedTree.getHeight()).thenReturn(nestedTreeHeight);
 when(LayoutState.resolveNestedTree(eq(mContext), eq(mNode), anyInt(), anyInt()))
   .thenReturn(nestedTree);
 when(mNode.getContext()).thenReturn(mContext);
 long output = measureFunction.measure(mNode.mYogaNode, 0, EXACTLY, 0, EXACTLY);
 PowerMockito.verifyStatic();
 LayoutState.resolveNestedTree(eq(mContext), eq(mNode), anyInt(), anyInt());
 assertThat(YogaMeasureOutput.getWidth(output)).isEqualTo(nestedTreeWidth);
 assertThat(YogaMeasureOutput.getHeight(output)).isEqualTo(nestedTreeHeight);
}

代码示例来源:origin: facebook/litho

return YogaMeasureOutput.make(outputWidth, outputHeight);

代码示例来源:origin: koudle/AndYogaSample

public static long make(float width, float height) {
 return make((int) width, (int) height);
}

代码示例来源:origin: facebook/litho

@Test
public void testLayoutSpecMeasureResolveNestedTree_withExperiment() {
 Component component =
   setUpSpyComponentForCreateLayout(false /* isMountSpec */, true /* canMeasure */);
 YogaMeasureFunction measureFunction = getMeasureFunction(component);
 final int nestedTreeWidth = 20;
 final int nestedTreeHeight = 25;
 InternalNode nestedTree = mock(InternalNode.class);
 when(nestedTree.getWidth()).thenReturn(nestedTreeWidth);
 when(nestedTree.getHeight()).thenReturn(nestedTreeHeight);
 when(LayoutState.resolveNestedTree(eq(mContext), eq(mNode), anyInt(), anyInt()))
   .thenReturn(nestedTree);
 when(mNode.getContext()).thenReturn(mContext);
 when(mContext.isNestedTreeResolutionExperimentEnabled()).thenReturn(true);
 when(mNode.getParent()).thenReturn(mNode);
 when(mNode.getContext()).thenReturn(mContext);
 long output = measureFunction.measure(mNode.mYogaNode, 0, EXACTLY, 0, EXACTLY);
 PowerMockito.verifyStatic();
 LayoutState.resolveNestedTree(eq(mContext), eq(mNode), anyInt(), anyInt());
 assertThat(YogaMeasureOutput.getWidth(output)).isEqualTo(nestedTreeWidth);
 assertThat(YogaMeasureOutput.getHeight(output)).isEqualTo(nestedTreeHeight);
}

代码示例来源:origin: facebook/litho

@Test
public void testMountSpecYogaMeasureOutputSet() {
 Component component = new TestMountSpecSettingSizesInOnMeasure(mNode);
 YogaMeasureFunction measureFunction = getMeasureFunction(component);
 long output = measureFunction.measure(mNode.mYogaNode, 0, EXACTLY, 0, EXACTLY);
 assertThat(YogaMeasureOutput.getWidth(output)).isEqualTo(A_WIDTH);
 assertThat(YogaMeasureOutput.getHeight(output)).isEqualTo(A_HEIGHT);
}

代码示例来源:origin: facebook/litho

@Test
public void measureAndCreateDiffNode() {
 final Component component = TestDrawableComponent.create(mContext)
   .build();
 InternalNode node = createInternalNodeForMeasurableComponent(component);
 long output = measureInternalNode(
   node,
   UNDEFINED,
   UNDEFINED);
 node.setCachedMeasuresValid(false);
 DiffNode diffNode = createDiffNode(node, null);
 assertThat(getHeight(output) == (int) diffNode.getLastMeasuredHeight()).isTrue();
 assertThat(getWidth(output) == (int) diffNode.getLastMeasuredWidth()).isTrue();
}

代码示例来源:origin: facebook/litho

@Test
public void testCachedMeasureFunction() {
 final Component component = TestDrawableComponent.create(mContext)
   .build();
 InternalNode node = createInternalNodeForMeasurableComponent(component);
 DiffNode diffNode = new DiffNode();
 diffNode.setLastHeightSpec(mUnspecifiedSpec);
 diffNode.setLastWidthSpec(mUnspecifiedSpec);
 diffNode.setLastMeasuredWidth(10);
 diffNode.setLastMeasuredHeight(5);
 diffNode.setComponent(component);
 node.setCachedMeasuresValid(true);
 node.setDiffNode(diffNode);
 long output = measureInternalNode(
   node,
   UNDEFINED,
   UNDEFINED);
 assertThat(getHeight(output) == (int) diffNode.getLastMeasuredHeight()).isTrue();
 assertThat(getWidth(output) == (int) diffNode.getLastMeasuredWidth()).isTrue();
}

代码示例来源:origin: facebook/litho

@Test
public void tesLastConstraints() {
 final Component component = TestDrawableComponent.create(mContext)
   .build();
 InternalNode node = createInternalNodeForMeasurableComponent(component);
 DiffNode diffNode = new DiffNode();
 diffNode.setLastWidthSpec(makeSizeSpec(10, SizeSpec.EXACTLY));
 diffNode.setLastHeightSpec(makeSizeSpec(5, SizeSpec.EXACTLY));
 diffNode.setLastMeasuredWidth(10f);
 diffNode.setLastMeasuredHeight(5f);
 diffNode.setComponent(component);
 node.setCachedMeasuresValid(true);
 node.setDiffNode(diffNode);
 long output = measureInternalNode(node, 10f, 5f);
 assertThat(getHeight(output) == (int) diffNode.getLastMeasuredHeight()).isTrue();
 assertThat(getWidth(output) == (int) diffNode.getLastMeasuredWidth()).isTrue();
 int lastWidthSpec = node.getLastWidthSpec();
 int lastHeightSpec = node.getLastHeightSpec();
 assertThat(getMode(lastWidthSpec) == SizeSpec.EXACTLY).isTrue();
 assertThat(getMode(lastHeightSpec) == SizeSpec.EXACTLY).isTrue();
 assertThat(getSize(lastWidthSpec) == 10).isTrue();
 assertThat(getSize(lastHeightSpec) == 5).isTrue();
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com