Add test case covering padding on child

Summary: Add coverage exposed by https://github.com/facebook/css-layout/pull/262

Reviewed By: splhack

Differential Revision: D4247282

fbshipit-source-id: 25500bcfced58a8095665b73eeebca8d1c266a17
This commit is contained in:
Emil Sjolander
2016-11-29 16:11:41 -08:00
committed by Facebook Github Bot
parent b32b6029de
commit 7d74e1cb66
4 changed files with 133 additions and 0 deletions

View File

@@ -202,4 +202,47 @@ public class CSSLayoutPaddingTest {
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
}
@Test
public void test_child_with_padding_align_end() {
final CSSNode root = new CSSNode();
root.setJustifyContent(CSSJustify.FLEX_END);
root.setAlignItems(CSSAlign.FLEX_END);
root.setWidth(200f);
root.setHeight(200f);
final CSSNode root_child0 = new CSSNode();
root_child0.setPadding(CSSEdge.LEFT, 20);
root_child0.setPadding(CSSEdge.TOP, 20);
root_child0.setPadding(CSSEdge.RIGHT, 20);
root_child0.setPadding(CSSEdge.BOTTOM, 20);
root_child0.setWidth(100f);
root_child0.setHeight(100f);
root.addChildAt(root_child0, 0);
root.setDirection(CSSDirection.LTR);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(200f, root.getLayoutHeight(), 0.0f);
assertEquals(100f, root_child0.getLayoutX(), 0.0f);
assertEquals(100f, root_child0.getLayoutY(), 0.0f);
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL);
root.calculateLayout();
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(200f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(100f, root_child0.getLayoutY(), 0.0f);
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
}
}