Add generated tests
Summary: - Add Java and C# test code generated by gentest Reviewed By: emilsjolander Differential Revision: D4065904 fbshipit-source-id: c0d489f37ee0a3132185636812057dc95725d59a
This commit is contained in:
committed by
Facebook Github Bot
parent
dc5e613285
commit
ef538a45cd
@@ -0,0 +1,259 @@
|
||||
/**
|
||||
* Copyright (c) 2014-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @Generated by gentest/gentest.sh with the following input
|
||||
*
|
||||
<div id="absolute_layout_width_height_start_top" style="width: 100px; height: 100px;">
|
||||
<div style="width:10px; height: 10px; position: absolute; start: 10px; top: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="absolute_layout_width_height_end_bottom" style="width: 100px; height: 100px;">
|
||||
<div style="width:10px; height: 10px; position: absolute; end: 10px; bottom: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="absolute_layout_start_top_end_bottom" style="width: 100px; height: 100px;">
|
||||
<div style="position: absolute; start: 10px; top: 10px; end: 10px; bottom: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="absolute_layout_width_height_start_top_end_bottom" style="width: 100px; height: 100px;">
|
||||
<div style="width:10px; height: 10px; position: absolute; start: 10px; top: 10px; end: 10px; bottom: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent" style="height: 50px; width: 50px; overflow: hidden; flex-direction: row;">
|
||||
<div style="position: absolute; start: 0; top: 0;">
|
||||
<div style="width: 100px; height: 100px;"></div>
|
||||
</div>
|
||||
</div>
|
||||
*
|
||||
*/
|
||||
|
||||
package com.facebook.csslayout;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class CSSLayoutAbsolutePositionTest {
|
||||
@Test
|
||||
public void test_absolute_layout_width_height_start_top() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setStyleWidth(100);
|
||||
root.setStyleHeight(100);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setPositionType(CSSPositionType.ABSOLUTE);
|
||||
root_child0.setPosition(Spacing.START, 10);
|
||||
root_child0.setPosition(Spacing.TOP, 10);
|
||||
root_child0.setStyleWidth(10);
|
||||
root_child0.setStyleHeight(10);
|
||||
root.addChildAt(root_child0, 0);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(10, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(80, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_absolute_layout_width_height_end_bottom() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setStyleWidth(100);
|
||||
root.setStyleHeight(100);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setPositionType(CSSPositionType.ABSOLUTE);
|
||||
root_child0.setPosition(Spacing.END, 10);
|
||||
root_child0.setPosition(Spacing.BOTTOM, 10);
|
||||
root_child0.setStyleWidth(10);
|
||||
root_child0.setStyleHeight(10);
|
||||
root.addChildAt(root_child0, 0);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(80, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(80, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(10, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(80, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_absolute_layout_start_top_end_bottom() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setStyleWidth(100);
|
||||
root.setStyleHeight(100);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setPositionType(CSSPositionType.ABSOLUTE);
|
||||
root_child0.setPosition(Spacing.START, 10);
|
||||
root_child0.setPosition(Spacing.TOP, 10);
|
||||
root_child0.setPosition(Spacing.END, 10);
|
||||
root_child0.setPosition(Spacing.BOTTOM, 10);
|
||||
root.addChildAt(root_child0, 0);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(10, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(80, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(80, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(10, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(80, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(80, root_child0.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_absolute_layout_width_height_start_top_end_bottom() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setStyleWidth(100);
|
||||
root.setStyleHeight(100);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setPositionType(CSSPositionType.ABSOLUTE);
|
||||
root_child0.setPosition(Spacing.START, 10);
|
||||
root_child0.setPosition(Spacing.TOP, 10);
|
||||
root_child0.setPosition(Spacing.END, 10);
|
||||
root_child0.setPosition(Spacing.BOTTOM, 10);
|
||||
root_child0.setStyleWidth(10);
|
||||
root_child0.setStyleHeight(10);
|
||||
root.addChildAt(root_child0, 0);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(10, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(80, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setFlexDirection(CSSFlexDirection.ROW);
|
||||
root.setOverflow(CSSOverflow.HIDDEN);
|
||||
root.setStyleWidth(50);
|
||||
root.setStyleHeight(50);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setPositionType(CSSPositionType.ABSOLUTE);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final CSSNode root_child0_child0 = new CSSNode();
|
||||
root_child0_child0.setStyleWidth(100);
|
||||
root_child0_child0.setStyleHeight(100);
|
||||
root_child0.addChildAt(root_child0_child0, 0);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(50, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child0_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root_child0_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(50, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(-50, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child0_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root_child0_child0.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
}
|
444
java/tests/com/facebook/csslayout/CSSLayoutAlignContentTest.java
Normal file
444
java/tests/com/facebook/csslayout/CSSLayoutAlignContentTest.java
Normal file
@@ -0,0 +1,444 @@
|
||||
/**
|
||||
* Copyright (c) 2014-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @Generated by gentest/gentest.sh with the following input
|
||||
*
|
||||
<div id="align_content_flex_start" style="width: 100px; height: 100px; flex-wrap: wrap; flex-direction: column; align-content: flex-start;">
|
||||
<div style="width: 50px; height: 10px;"></div>
|
||||
<div style="width: 50px; height: 10px;"></div>
|
||||
<div style="width: 50px; height: 10px;"></div>
|
||||
<div style="width: 50px; height: 10px;"></div>
|
||||
<div style="width: 50px; height: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="align_content_flex_end" style="width: 100px; height: 100px; flex-wrap: wrap; flex-direction: column; align-content: flex-end;">
|
||||
<div style="width: 50px; height: 10px;"></div>
|
||||
<div style="width: 50px; height: 10px;"></div>
|
||||
<div style="width: 50px; height: 10px;"></div>
|
||||
<div style="width: 50px; height: 10px;"></div>
|
||||
<div style="width: 50px; height: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="align_content_center" style="width: 100px; height: 100px; flex-wrap: wrap; flex-direction: column; align-content: center;">
|
||||
<div style="width: 50px; height: 10px;"></div>
|
||||
<div style="width: 50px; height: 10px;"></div>
|
||||
<div style="width: 50px; height: 10px;"></div>
|
||||
<div style="width: 50px; height: 10px;"></div>
|
||||
<div style="width: 50px; height: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="align_content_stretch" style="width: 100px; height: 100px; flex-wrap: wrap; flex-direction: column; align-content: stretch;">
|
||||
<div style="width: 50px;"></div>
|
||||
<div style="width: 50px;"></div>
|
||||
<div style="width: 50px;"></div>
|
||||
<div style="width: 50px;"></div>
|
||||
<div style="width: 50px;"></div>
|
||||
</div>
|
||||
*
|
||||
*/
|
||||
|
||||
package com.facebook.csslayout;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class CSSLayoutAlignContentTest {
|
||||
@Test
|
||||
public void test_align_content_flex_start() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setWrap(CSSWrap.WRAP);
|
||||
root.setStyleWidth(100);
|
||||
root.setStyleHeight(100);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setStyleWidth(50);
|
||||
root_child0.setStyleHeight(10);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final CSSNode root_child1 = new CSSNode();
|
||||
root_child1.setStyleWidth(50);
|
||||
root_child1.setStyleHeight(10);
|
||||
root.addChildAt(root_child1, 1);
|
||||
|
||||
final CSSNode root_child2 = new CSSNode();
|
||||
root_child2.setStyleWidth(50);
|
||||
root_child2.setStyleHeight(10);
|
||||
root.addChildAt(root_child2, 2);
|
||||
|
||||
final CSSNode root_child3 = new CSSNode();
|
||||
root_child3.setStyleWidth(50);
|
||||
root_child3.setStyleHeight(10);
|
||||
root.addChildAt(root_child3, 3);
|
||||
|
||||
final CSSNode root_child4 = new CSSNode();
|
||||
root_child4.setStyleWidth(50);
|
||||
root_child4.setStyleHeight(10);
|
||||
root.addChildAt(root_child4, 4);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(10, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(20, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child3.getLayoutX(), 0.0f);
|
||||
assertEquals(30, root_child3.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child3.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child3.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child4.getLayoutX(), 0.0f);
|
||||
assertEquals(40, root_child4.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child4.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child4.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(50, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(50, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(10, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(50, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(20, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(50, root_child3.getLayoutX(), 0.0f);
|
||||
assertEquals(30, root_child3.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child3.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child3.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(50, root_child4.getLayoutX(), 0.0f);
|
||||
assertEquals(40, root_child4.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child4.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child4.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_align_content_flex_end() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setAlignContent(CSSAlign.FLEX_END);
|
||||
root.setWrap(CSSWrap.WRAP);
|
||||
root.setStyleWidth(100);
|
||||
root.setStyleHeight(100);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setStyleWidth(50);
|
||||
root_child0.setStyleHeight(10);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final CSSNode root_child1 = new CSSNode();
|
||||
root_child1.setStyleWidth(50);
|
||||
root_child1.setStyleHeight(10);
|
||||
root.addChildAt(root_child1, 1);
|
||||
|
||||
final CSSNode root_child2 = new CSSNode();
|
||||
root_child2.setStyleWidth(50);
|
||||
root_child2.setStyleHeight(10);
|
||||
root.addChildAt(root_child2, 2);
|
||||
|
||||
final CSSNode root_child3 = new CSSNode();
|
||||
root_child3.setStyleWidth(50);
|
||||
root_child3.setStyleHeight(10);
|
||||
root.addChildAt(root_child3, 3);
|
||||
|
||||
final CSSNode root_child4 = new CSSNode();
|
||||
root_child4.setStyleWidth(50);
|
||||
root_child4.setStyleHeight(10);
|
||||
root.addChildAt(root_child4, 4);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(10, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(20, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child3.getLayoutX(), 0.0f);
|
||||
assertEquals(30, root_child3.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child3.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child3.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child4.getLayoutX(), 0.0f);
|
||||
assertEquals(40, root_child4.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child4.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child4.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(50, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(50, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(10, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(50, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(20, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(50, root_child3.getLayoutX(), 0.0f);
|
||||
assertEquals(30, root_child3.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child3.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child3.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(50, root_child4.getLayoutX(), 0.0f);
|
||||
assertEquals(40, root_child4.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child4.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child4.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_align_content_center() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setAlignContent(CSSAlign.CENTER);
|
||||
root.setWrap(CSSWrap.WRAP);
|
||||
root.setStyleWidth(100);
|
||||
root.setStyleHeight(100);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setStyleWidth(50);
|
||||
root_child0.setStyleHeight(10);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final CSSNode root_child1 = new CSSNode();
|
||||
root_child1.setStyleWidth(50);
|
||||
root_child1.setStyleHeight(10);
|
||||
root.addChildAt(root_child1, 1);
|
||||
|
||||
final CSSNode root_child2 = new CSSNode();
|
||||
root_child2.setStyleWidth(50);
|
||||
root_child2.setStyleHeight(10);
|
||||
root.addChildAt(root_child2, 2);
|
||||
|
||||
final CSSNode root_child3 = new CSSNode();
|
||||
root_child3.setStyleWidth(50);
|
||||
root_child3.setStyleHeight(10);
|
||||
root.addChildAt(root_child3, 3);
|
||||
|
||||
final CSSNode root_child4 = new CSSNode();
|
||||
root_child4.setStyleWidth(50);
|
||||
root_child4.setStyleHeight(10);
|
||||
root.addChildAt(root_child4, 4);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(10, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(20, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child3.getLayoutX(), 0.0f);
|
||||
assertEquals(30, root_child3.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child3.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child3.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child4.getLayoutX(), 0.0f);
|
||||
assertEquals(40, root_child4.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child4.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child4.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(50, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(50, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(10, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(50, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(20, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(50, root_child3.getLayoutX(), 0.0f);
|
||||
assertEquals(30, root_child3.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child3.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child3.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(50, root_child4.getLayoutX(), 0.0f);
|
||||
assertEquals(40, root_child4.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child4.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child4.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_align_content_stretch() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setAlignContent(CSSAlign.STRETCH);
|
||||
root.setWrap(CSSWrap.WRAP);
|
||||
root.setStyleWidth(100);
|
||||
root.setStyleHeight(100);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setStyleWidth(50);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final CSSNode root_child1 = new CSSNode();
|
||||
root_child1.setStyleWidth(50);
|
||||
root.addChildAt(root_child1, 1);
|
||||
|
||||
final CSSNode root_child2 = new CSSNode();
|
||||
root_child2.setStyleWidth(50);
|
||||
root.addChildAt(root_child2, 2);
|
||||
|
||||
final CSSNode root_child3 = new CSSNode();
|
||||
root_child3.setStyleWidth(50);
|
||||
root.addChildAt(root_child3, 3);
|
||||
|
||||
final CSSNode root_child4 = new CSSNode();
|
||||
root_child4.setStyleWidth(50);
|
||||
root.addChildAt(root_child4, 4);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(0, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(0, root_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child3.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child3.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child3.getLayoutWidth(), 0.0f);
|
||||
assertEquals(0, root_child3.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child4.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child4.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child4.getLayoutWidth(), 0.0f);
|
||||
assertEquals(0, root_child4.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(50, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(50, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(0, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(50, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(0, root_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(50, root_child3.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child3.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child3.getLayoutWidth(), 0.0f);
|
||||
assertEquals(0, root_child3.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(50, root_child4.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child4.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child4.getLayoutWidth(), 0.0f);
|
||||
assertEquals(0, root_child4.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
}
|
188
java/tests/com/facebook/csslayout/CSSLayoutAlignItemsTest.java
Normal file
188
java/tests/com/facebook/csslayout/CSSLayoutAlignItemsTest.java
Normal file
@@ -0,0 +1,188 @@
|
||||
/**
|
||||
* Copyright (c) 2014-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @Generated by gentest/gentest.sh with the following input
|
||||
*
|
||||
<div id="align_items_stretch" style="width: 100px; height: 100px;">
|
||||
<div style="height: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="align_items_center" style="width: 100px; height: 100px; align-items: center;">
|
||||
<div style="height: 10px; width: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="align_items_flex_start" style="width: 100px; height: 100px; align-items: flex-start;">
|
||||
<div style="height: 10px; width: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="align_items_flex_end" style="width: 100px; height: 100px; align-items: flex-end;">
|
||||
<div style="height: 10px; width: 10px;"></div>
|
||||
</div>
|
||||
*
|
||||
*/
|
||||
|
||||
package com.facebook.csslayout;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class CSSLayoutAlignItemsTest {
|
||||
@Test
|
||||
public void test_align_items_stretch() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setStyleWidth(100);
|
||||
root.setStyleHeight(100);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setStyleHeight(10);
|
||||
root.addChildAt(root_child0, 0);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_align_items_center() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setAlignItems(CSSAlign.CENTER);
|
||||
root.setStyleWidth(100);
|
||||
root.setStyleHeight(100);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setStyleWidth(10);
|
||||
root_child0.setStyleHeight(10);
|
||||
root.addChildAt(root_child0, 0);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(45, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(45, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_align_items_flex_start() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setAlignItems(CSSAlign.FLEX_START);
|
||||
root.setStyleWidth(100);
|
||||
root.setStyleHeight(100);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setStyleWidth(10);
|
||||
root_child0.setStyleHeight(10);
|
||||
root.addChildAt(root_child0, 0);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(90, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_align_items_flex_end() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setAlignItems(CSSAlign.FLEX_END);
|
||||
root.setStyleWidth(100);
|
||||
root.setStyleHeight(100);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setStyleWidth(10);
|
||||
root_child0.setStyleHeight(10);
|
||||
root.addChildAt(root_child0, 0);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(90, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
}
|
191
java/tests/com/facebook/csslayout/CSSLayoutAlignSelfTest.java
Normal file
191
java/tests/com/facebook/csslayout/CSSLayoutAlignSelfTest.java
Normal file
@@ -0,0 +1,191 @@
|
||||
/**
|
||||
* Copyright (c) 2014-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @Generated by gentest/gentest.sh with the following input
|
||||
*
|
||||
<div id="align_self_center" style="width:100px; height: 100px;">
|
||||
<div style="height: 10px; width: 10px; align-self: center;"></div>
|
||||
</div>
|
||||
|
||||
<div id="align_self_flex_end" style="width:100px; height: 100px;">
|
||||
<div style="height: 10px; width: 10px; align-self: flex-end;"></div>
|
||||
</div>
|
||||
|
||||
<div id="align_self_flex_start" style="width:100px; height: 100px;">
|
||||
<div style="height: 10px; width: 10px; align-self: flex-start;"></div>
|
||||
</div>
|
||||
|
||||
<div id="align_self_flex_end_override_flex_start" style="width:100px; height: 100px; align-items: flex-start;">
|
||||
<div style="height: 10px; width: 10px; align-self: flex-end;"></div>
|
||||
</div>
|
||||
*
|
||||
*/
|
||||
|
||||
package com.facebook.csslayout;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class CSSLayoutAlignSelfTest {
|
||||
@Test
|
||||
public void test_align_self_center() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setStyleWidth(100);
|
||||
root.setStyleHeight(100);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setAlignSelf(CSSAlign.CENTER);
|
||||
root_child0.setStyleWidth(10);
|
||||
root_child0.setStyleHeight(10);
|
||||
root.addChildAt(root_child0, 0);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(45, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(45, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_align_self_flex_end() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setStyleWidth(100);
|
||||
root.setStyleHeight(100);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setAlignSelf(CSSAlign.FLEX_END);
|
||||
root_child0.setStyleWidth(10);
|
||||
root_child0.setStyleHeight(10);
|
||||
root.addChildAt(root_child0, 0);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(90, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_align_self_flex_start() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setStyleWidth(100);
|
||||
root.setStyleHeight(100);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setAlignSelf(CSSAlign.FLEX_START);
|
||||
root_child0.setStyleWidth(10);
|
||||
root_child0.setStyleHeight(10);
|
||||
root.addChildAt(root_child0, 0);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(90, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_align_self_flex_end_override_flex_start() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setAlignItems(CSSAlign.FLEX_START);
|
||||
root.setStyleWidth(100);
|
||||
root.setStyleHeight(100);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setAlignSelf(CSSAlign.FLEX_END);
|
||||
root_child0.setStyleWidth(10);
|
||||
root_child0.setStyleHeight(10);
|
||||
root.addChildAt(root_child0, 0);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(90, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
}
|
227
java/tests/com/facebook/csslayout/CSSLayoutBorderTest.java
Normal file
227
java/tests/com/facebook/csslayout/CSSLayoutBorderTest.java
Normal file
@@ -0,0 +1,227 @@
|
||||
/**
|
||||
* Copyright (c) 2014-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @Generated by gentest/gentest.sh with the following input
|
||||
*
|
||||
<div id="border_no_size" style="border-width: 10px;">
|
||||
</div>
|
||||
|
||||
<div id="border_container_match_child" style="border-width: 10px;">
|
||||
<div style="width: 10px; height: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="border_flex_child" style="width: 100px; height: 100px; border-width: 10px;">
|
||||
<div style="width: 10px; flex-grow:1"></div>
|
||||
</div>
|
||||
|
||||
<div id="border_stretch_child" style="width: 100px; height: 100px; border-width: 10px;">
|
||||
<div style="height: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="border_center_child" style="width: 100px; height: 100px; border-start-width: 10px; border-top-width: 10; border-end-width: 20px; border-bottom-width: 20px; align-items: center; justify-content: center;">
|
||||
<div style="height: 10px; width: 10px;"></div>
|
||||
</div>
|
||||
*
|
||||
*/
|
||||
|
||||
package com.facebook.csslayout;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class CSSLayoutBorderTest {
|
||||
@Test
|
||||
public void test_border_no_size() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setBorder(Spacing.LEFT, 10);
|
||||
root.setBorder(Spacing.TOP, 10);
|
||||
root.setBorder(Spacing.RIGHT, 10);
|
||||
root.setBorder(Spacing.BOTTOM, 10);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(20, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(20, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(20, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(20, root.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_border_container_match_child() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setBorder(Spacing.LEFT, 10);
|
||||
root.setBorder(Spacing.TOP, 10);
|
||||
root.setBorder(Spacing.RIGHT, 10);
|
||||
root.setBorder(Spacing.BOTTOM, 10);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setStyleWidth(10);
|
||||
root_child0.setStyleHeight(10);
|
||||
root.addChildAt(root_child0, 0);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(30, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(30, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(10, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(30, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(30, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(10, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_border_flex_child() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setBorder(Spacing.LEFT, 10);
|
||||
root.setBorder(Spacing.TOP, 10);
|
||||
root.setBorder(Spacing.RIGHT, 10);
|
||||
root.setBorder(Spacing.BOTTOM, 10);
|
||||
root.setStyleWidth(100);
|
||||
root.setStyleHeight(100);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setFlexGrow(1);
|
||||
root_child0.setStyleWidth(10);
|
||||
root.addChildAt(root_child0, 0);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(10, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(80, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(80, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(80, root_child0.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_border_stretch_child() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setBorder(Spacing.LEFT, 10);
|
||||
root.setBorder(Spacing.TOP, 10);
|
||||
root.setBorder(Spacing.RIGHT, 10);
|
||||
root.setBorder(Spacing.BOTTOM, 10);
|
||||
root.setStyleWidth(100);
|
||||
root.setStyleHeight(100);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setStyleHeight(10);
|
||||
root.addChildAt(root_child0, 0);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(10, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(80, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(10, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(80, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_border_center_child() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setJustifyContent(CSSJustify.CENTER);
|
||||
root.setAlignItems(CSSAlign.CENTER);
|
||||
root.setBorder(Spacing.START, 10);
|
||||
root.setBorder(Spacing.END, 20);
|
||||
root.setBorder(Spacing.BOTTOM, 20);
|
||||
root.setStyleWidth(100);
|
||||
root.setStyleHeight(100);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setStyleWidth(10);
|
||||
root_child0.setStyleHeight(10);
|
||||
root.addChildAt(root_child0, 0);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(40, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(35, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(50, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(35, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,444 @@
|
||||
/**
|
||||
* Copyright (c) 2014-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @Generated by gentest/gentest.sh with the following input
|
||||
*
|
||||
<div id="flex_direction_column_no_height" style="width: 100px">
|
||||
<div style="height: 10px;"></div>
|
||||
<div style="height: 10px;"></div>
|
||||
<div style="height: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="flex_direction_row_no_width" style="height: 100px; flex-direction: row;">
|
||||
<div style="width: 10px;"></div>
|
||||
<div style="width: 10px;"></div>
|
||||
<div style="width: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="flex_direction_column" style="height: 100px; width: 100px;">
|
||||
<div style="height: 10px;"></div>
|
||||
<div style="height: 10px;"></div>
|
||||
<div style="height: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="flex_direction_row" style="height: 100px; width: 100px; flex-direction: row;">
|
||||
<div style="width: 10px;"></div>
|
||||
<div style="width: 10px;"></div>
|
||||
<div style="width: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="flex_direction_column_reverse" style="height: 100px; width: 100px; flex-direction: column-reverse;">
|
||||
<div style="height: 10px;"></div>
|
||||
<div style="height: 10px;"></div>
|
||||
<div style="height: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="flex_direction_row_reverse" style="height: 100px; width: 100px; flex-direction: row-reverse;">
|
||||
<div style="width: 10px;"></div>
|
||||
<div style="width: 10px;"></div>
|
||||
<div style="width: 10px;"></div>
|
||||
</div>
|
||||
*
|
||||
*/
|
||||
|
||||
package com.facebook.csslayout;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class CSSLayoutFlexDirectionTest {
|
||||
@Test
|
||||
public void test_flex_direction_column_no_height() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setStyleWidth(100);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setStyleHeight(10);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final CSSNode root_child1 = new CSSNode();
|
||||
root_child1.setStyleHeight(10);
|
||||
root.addChildAt(root_child1, 1);
|
||||
|
||||
final CSSNode root_child2 = new CSSNode();
|
||||
root_child2.setStyleHeight(10);
|
||||
root.addChildAt(root_child2, 2);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(30, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(10, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(20, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(30, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(10, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(20, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child2.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_flex_direction_row_no_width() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setFlexDirection(CSSFlexDirection.ROW);
|
||||
root.setStyleHeight(100);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setStyleWidth(10);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final CSSNode root_child1 = new CSSNode();
|
||||
root_child1.setStyleWidth(10);
|
||||
root.addChildAt(root_child1, 1);
|
||||
|
||||
final CSSNode root_child2 = new CSSNode();
|
||||
root_child2.setStyleWidth(10);
|
||||
root.addChildAt(root_child2, 2);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(30, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(10, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(20, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(30, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(20, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(10, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root_child2.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_flex_direction_column() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setStyleWidth(100);
|
||||
root.setStyleHeight(100);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setStyleHeight(10);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final CSSNode root_child1 = new CSSNode();
|
||||
root_child1.setStyleHeight(10);
|
||||
root.addChildAt(root_child1, 1);
|
||||
|
||||
final CSSNode root_child2 = new CSSNode();
|
||||
root_child2.setStyleHeight(10);
|
||||
root.addChildAt(root_child2, 2);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(10, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(20, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(10, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(20, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child2.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_flex_direction_row() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setFlexDirection(CSSFlexDirection.ROW);
|
||||
root.setStyleWidth(100);
|
||||
root.setStyleHeight(100);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setStyleWidth(10);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final CSSNode root_child1 = new CSSNode();
|
||||
root_child1.setStyleWidth(10);
|
||||
root.addChildAt(root_child1, 1);
|
||||
|
||||
final CSSNode root_child2 = new CSSNode();
|
||||
root_child2.setStyleWidth(10);
|
||||
root.addChildAt(root_child2, 2);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(10, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(20, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(90, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(80, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(70, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root_child2.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_flex_direction_column_reverse() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setFlexDirection(CSSFlexDirection.COLUMN_REVERSE);
|
||||
root.setStyleWidth(100);
|
||||
root.setStyleHeight(100);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setStyleHeight(10);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final CSSNode root_child1 = new CSSNode();
|
||||
root_child1.setStyleHeight(10);
|
||||
root.addChildAt(root_child1, 1);
|
||||
|
||||
final CSSNode root_child2 = new CSSNode();
|
||||
root_child2.setStyleHeight(10);
|
||||
root.addChildAt(root_child2, 2);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(90, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(80, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(70, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(90, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(80, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(70, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child2.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_flex_direction_row_reverse() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setFlexDirection(CSSFlexDirection.ROW_REVERSE);
|
||||
root.setStyleWidth(100);
|
||||
root.setStyleHeight(100);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setStyleWidth(10);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final CSSNode root_child1 = new CSSNode();
|
||||
root_child1.setStyleWidth(10);
|
||||
root.addChildAt(root_child1, 1);
|
||||
|
||||
final CSSNode root_child2 = new CSSNode();
|
||||
root_child2.setStyleWidth(10);
|
||||
root.addChildAt(root_child2, 2);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(90, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(80, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(70, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(10, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(20, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root_child2.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
}
|
395
java/tests/com/facebook/csslayout/CSSLayoutFlexTest.java
Normal file
395
java/tests/com/facebook/csslayout/CSSLayoutFlexTest.java
Normal file
@@ -0,0 +1,395 @@
|
||||
/**
|
||||
* Copyright (c) 2014-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @Generated by gentest/gentest.sh with the following input
|
||||
*
|
||||
<div id="flex_basis_flex_grow_column" style="width: 100px; height: 100px;">
|
||||
<div style="flex-basis: 50px; flex-grow: 1;"></div>
|
||||
<div style="flex-grow: 1;"></div>
|
||||
</div>
|
||||
|
||||
<div id="flex_basis_flex_grow_row" style="width: 100px; height: 100px; flex-direction: row;">
|
||||
<div style="flex-basis: 50px; flex-grow: 1;"></div>
|
||||
<div style="flex-grow: 1;"></div>
|
||||
</div>
|
||||
|
||||
<div id="flex_basis_flex_shrink_column" style="width: 100px; height: 100px;">
|
||||
<div style="flex-basis: 100px; flex-shrink: 1;"></div>
|
||||
<div style="flex-basis: 50px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="flex_basis_flex_shrink_row" style="width: 100px; height: 100px; flex-direction: row;">
|
||||
<div style="flex-basis: 100px; flex-shrink: 1;"></div>
|
||||
<div style="flex-basis: 50px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="flex_shrink_to_zero" style="height: 75px;">
|
||||
<div style="width: 50px; height: 50px; flex-shrink:0;"></div>
|
||||
<div style="width: 50px; height: 50px; flex-shrink:1;"></div>
|
||||
<div style="width: 50px; height: 50px; flex-shrink:0;"></div>
|
||||
</div>
|
||||
|
||||
<div id="flex_basis_overrides_main_size" style="height: 100px; width: 100px;">
|
||||
<div style="height: 20px; flex-grow:1; flex-basis:50px;"></div>
|
||||
<div style="height: 10px; flex-grow:1;"></div>
|
||||
<div style="height: 10px; flex-grow:1;"></div>
|
||||
</div>
|
||||
*
|
||||
*/
|
||||
|
||||
package com.facebook.csslayout;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class CSSLayoutFlexTest {
|
||||
@Test
|
||||
public void test_flex_basis_flex_grow_column() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setStyleWidth(100);
|
||||
root.setStyleHeight(100);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setFlexGrow(1);
|
||||
root_child0.setFlexBasis(50);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final CSSNode root_child1 = new CSSNode();
|
||||
root_child1.setFlexGrow(1);
|
||||
root.addChildAt(root_child1, 1);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(75, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(75, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(25, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(75, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(75, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(25, root_child1.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_flex_basis_flex_grow_row() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setFlexDirection(CSSFlexDirection.ROW);
|
||||
root.setStyleWidth(100);
|
||||
root.setStyleHeight(100);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setFlexGrow(1);
|
||||
root_child0.setFlexBasis(50);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final CSSNode root_child1 = new CSSNode();
|
||||
root_child1.setFlexGrow(1);
|
||||
root.addChildAt(root_child1, 1);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(75, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(75, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(25, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(25, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(75, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(25, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root_child1.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_flex_basis_flex_shrink_column() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setStyleWidth(100);
|
||||
root.setStyleHeight(100);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setFlexShrink(1);
|
||||
root_child0.setFlexBasis(100);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final CSSNode root_child1 = new CSSNode();
|
||||
root_child1.setFlexBasis(50);
|
||||
root.addChildAt(root_child1, 1);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(50, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(50, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(50, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(50, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(50, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(50, root_child1.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_flex_basis_flex_shrink_row() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setFlexDirection(CSSFlexDirection.ROW);
|
||||
root.setStyleWidth(100);
|
||||
root.setStyleHeight(100);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setFlexShrink(1);
|
||||
root_child0.setFlexBasis(100);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final CSSNode root_child1 = new CSSNode();
|
||||
root_child1.setFlexBasis(50);
|
||||
root.addChildAt(root_child1, 1);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(50, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(50, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root_child1.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_flex_shrink_to_zero() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setStyleHeight(75);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setStyleWidth(50);
|
||||
root_child0.setStyleHeight(50);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final CSSNode root_child1 = new CSSNode();
|
||||
root_child1.setFlexShrink(1);
|
||||
root_child1.setStyleWidth(50);
|
||||
root_child1.setStyleHeight(50);
|
||||
root.addChildAt(root_child1, 1);
|
||||
|
||||
final CSSNode root_child2 = new CSSNode();
|
||||
root_child2.setStyleWidth(50);
|
||||
root_child2.setStyleHeight(50);
|
||||
root.addChildAt(root_child2, 2);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(75, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(50, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(50, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(0, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(50, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(50, root_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(75, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(50, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(50, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(0, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(50, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(50, root_child2.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_flex_basis_overrides_main_size() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setStyleWidth(100);
|
||||
root.setStyleHeight(100);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setFlexGrow(1);
|
||||
root_child0.setFlexBasis(50);
|
||||
root_child0.setStyleHeight(20);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final CSSNode root_child1 = new CSSNode();
|
||||
root_child1.setFlexGrow(1);
|
||||
root_child1.setStyleHeight(10);
|
||||
root.addChildAt(root_child1, 1);
|
||||
|
||||
final CSSNode root_child2 = new CSSNode();
|
||||
root_child2.setFlexGrow(1);
|
||||
root_child2.setStyleHeight(10);
|
||||
root.addChildAt(root_child2, 2);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(60, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(60, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(20, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(80, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(20, root_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(60, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(60, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(20, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(80, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(20, root_child2.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
}
|
383
java/tests/com/facebook/csslayout/CSSLayoutFlexWrapTest.java
Normal file
383
java/tests/com/facebook/csslayout/CSSLayoutFlexWrapTest.java
Normal file
@@ -0,0 +1,383 @@
|
||||
/**
|
||||
* Copyright (c) 2014-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @Generated by gentest/gentest.sh with the following input
|
||||
*
|
||||
<div id="wrap_column" style="height: 100px; flex-wrap: wrap">
|
||||
<div style="height: 30px; width: 30px;"></div>
|
||||
<div style="height: 30px; width: 30px;"></div>
|
||||
<div style="height: 30px; width: 30px;"></div>
|
||||
<div style="height: 30px; width: 30px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="wrap_row" style="width: 100px; flex-direction: row; flex-wrap: wrap">
|
||||
<div style="height: 30px; width: 30px;"></div>
|
||||
<div style="height: 30px; width: 30px;"></div>
|
||||
<div style="height: 30px; width: 30px;"></div>
|
||||
<div style="height: 30px; width: 30px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="wrap_row_align_items_flex_end" style="width: 100px; flex-direction: row; flex-wrap: wrap; align-items: flex-end;">
|
||||
<div style="height: 10px; width: 30px;"></div>
|
||||
<div style="height: 20px; width: 30px;"></div>
|
||||
<div style="height: 30px; width: 30px;"></div>
|
||||
<div style="height: 30px; width: 30px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="wrap_row_align_items_center" style="width: 100px; flex-direction: row; flex-wrap: wrap; align-items: center;">
|
||||
<div style="height: 10px; width: 30px;"></div>
|
||||
<div style="height: 20px; width: 30px;"></div>
|
||||
<div style="height: 30px; width: 30px;"></div>
|
||||
<div style="height: 30px; width: 30px;"></div>
|
||||
</div>
|
||||
*
|
||||
*/
|
||||
|
||||
package com.facebook.csslayout;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class CSSLayoutFlexWrapTest {
|
||||
@Test
|
||||
public void test_wrap_column() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setWrap(CSSWrap.WRAP);
|
||||
root.setStyleHeight(100);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setStyleWidth(30);
|
||||
root_child0.setStyleHeight(30);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final CSSNode root_child1 = new CSSNode();
|
||||
root_child1.setStyleWidth(30);
|
||||
root_child1.setStyleHeight(30);
|
||||
root.addChildAt(root_child1, 1);
|
||||
|
||||
final CSSNode root_child2 = new CSSNode();
|
||||
root_child2.setStyleWidth(30);
|
||||
root_child2.setStyleHeight(30);
|
||||
root.addChildAt(root_child2, 2);
|
||||
|
||||
final CSSNode root_child3 = new CSSNode();
|
||||
root_child3.setStyleWidth(30);
|
||||
root_child3.setStyleHeight(30);
|
||||
root.addChildAt(root_child3, 3);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(60, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(30, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(30, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(30, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(30, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(30, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(60, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(30, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(30, root_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(30, root_child3.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child3.getLayoutY(), 0.0f);
|
||||
assertEquals(30, root_child3.getLayoutWidth(), 0.0f);
|
||||
assertEquals(30, root_child3.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(60, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(30, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(30, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(30, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(30, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(30, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(30, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(30, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(30, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(60, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(30, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(30, root_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child3.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child3.getLayoutY(), 0.0f);
|
||||
assertEquals(30, root_child3.getLayoutWidth(), 0.0f);
|
||||
assertEquals(30, root_child3.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_wrap_row() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setFlexDirection(CSSFlexDirection.ROW);
|
||||
root.setWrap(CSSWrap.WRAP);
|
||||
root.setStyleWidth(100);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setStyleWidth(30);
|
||||
root_child0.setStyleHeight(30);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final CSSNode root_child1 = new CSSNode();
|
||||
root_child1.setStyleWidth(30);
|
||||
root_child1.setStyleHeight(30);
|
||||
root.addChildAt(root_child1, 1);
|
||||
|
||||
final CSSNode root_child2 = new CSSNode();
|
||||
root_child2.setStyleWidth(30);
|
||||
root_child2.setStyleHeight(30);
|
||||
root.addChildAt(root_child2, 2);
|
||||
|
||||
final CSSNode root_child3 = new CSSNode();
|
||||
root_child3.setStyleWidth(30);
|
||||
root_child3.setStyleHeight(30);
|
||||
root.addChildAt(root_child3, 3);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(60, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(30, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(30, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(30, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(30, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(30, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(60, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(30, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(30, root_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child3.getLayoutX(), 0.0f);
|
||||
assertEquals(30, root_child3.getLayoutY(), 0.0f);
|
||||
assertEquals(30, root_child3.getLayoutWidth(), 0.0f);
|
||||
assertEquals(30, root_child3.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(60, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(70, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(30, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(30, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(40, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(30, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(30, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(10, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(30, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(30, root_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(70, root_child3.getLayoutX(), 0.0f);
|
||||
assertEquals(30, root_child3.getLayoutY(), 0.0f);
|
||||
assertEquals(30, root_child3.getLayoutWidth(), 0.0f);
|
||||
assertEquals(30, root_child3.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_wrap_row_align_items_flex_end() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setFlexDirection(CSSFlexDirection.ROW);
|
||||
root.setAlignItems(CSSAlign.FLEX_END);
|
||||
root.setWrap(CSSWrap.WRAP);
|
||||
root.setStyleWidth(100);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setStyleWidth(30);
|
||||
root_child0.setStyleHeight(10);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final CSSNode root_child1 = new CSSNode();
|
||||
root_child1.setStyleWidth(30);
|
||||
root_child1.setStyleHeight(20);
|
||||
root.addChildAt(root_child1, 1);
|
||||
|
||||
final CSSNode root_child2 = new CSSNode();
|
||||
root_child2.setStyleWidth(30);
|
||||
root_child2.setStyleHeight(30);
|
||||
root.addChildAt(root_child2, 2);
|
||||
|
||||
final CSSNode root_child3 = new CSSNode();
|
||||
root_child3.setStyleWidth(30);
|
||||
root_child3.setStyleHeight(30);
|
||||
root.addChildAt(root_child3, 3);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(60, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(20, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(30, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(30, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(10, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(30, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(20, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(60, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(30, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(30, root_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child3.getLayoutX(), 0.0f);
|
||||
assertEquals(30, root_child3.getLayoutY(), 0.0f);
|
||||
assertEquals(30, root_child3.getLayoutWidth(), 0.0f);
|
||||
assertEquals(30, root_child3.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(60, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(70, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(20, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(30, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(40, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(10, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(30, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(20, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(10, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(30, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(30, root_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(70, root_child3.getLayoutX(), 0.0f);
|
||||
assertEquals(30, root_child3.getLayoutY(), 0.0f);
|
||||
assertEquals(30, root_child3.getLayoutWidth(), 0.0f);
|
||||
assertEquals(30, root_child3.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_wrap_row_align_items_center() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setFlexDirection(CSSFlexDirection.ROW);
|
||||
root.setAlignItems(CSSAlign.CENTER);
|
||||
root.setWrap(CSSWrap.WRAP);
|
||||
root.setStyleWidth(100);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setStyleWidth(30);
|
||||
root_child0.setStyleHeight(10);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final CSSNode root_child1 = new CSSNode();
|
||||
root_child1.setStyleWidth(30);
|
||||
root_child1.setStyleHeight(20);
|
||||
root.addChildAt(root_child1, 1);
|
||||
|
||||
final CSSNode root_child2 = new CSSNode();
|
||||
root_child2.setStyleWidth(30);
|
||||
root_child2.setStyleHeight(30);
|
||||
root.addChildAt(root_child2, 2);
|
||||
|
||||
final CSSNode root_child3 = new CSSNode();
|
||||
root_child3.setStyleWidth(30);
|
||||
root_child3.setStyleHeight(30);
|
||||
root.addChildAt(root_child3, 3);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(60, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(30, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(30, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(5, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(30, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(20, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(60, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(30, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(30, root_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child3.getLayoutX(), 0.0f);
|
||||
assertEquals(30, root_child3.getLayoutY(), 0.0f);
|
||||
assertEquals(30, root_child3.getLayoutWidth(), 0.0f);
|
||||
assertEquals(30, root_child3.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(60, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(70, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(30, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(40, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(5, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(30, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(20, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(10, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(30, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(30, root_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(70, root_child3.getLayoutX(), 0.0f);
|
||||
assertEquals(30, root_child3.getLayoutY(), 0.0f);
|
||||
assertEquals(30, root_child3.getLayoutWidth(), 0.0f);
|
||||
assertEquals(30, root_child3.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,734 @@
|
||||
/**
|
||||
* Copyright (c) 2014-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @Generated by gentest/gentest.sh with the following input
|
||||
*
|
||||
<div id="justify_content_row_flex_start" style="width: 102px; height: 102px; flex-direction: row; justify-content: flex-start;">
|
||||
<div style="width: 10px;"></div>
|
||||
<div style="width: 10px;"></div>
|
||||
<div style="width: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="justify_content_row_flex_end" style="width: 102px; height: 102px; flex-direction: row; justify-content: flex-end;">
|
||||
<div style="width: 10px;"></div>
|
||||
<div style="width: 10px;"></div>
|
||||
<div style="width: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="justify_content_row_center" style="width: 102px; height: 102px; flex-direction: row; justify-content: center;">
|
||||
<div style="width: 10px;"></div>
|
||||
<div style="width: 10px;"></div>
|
||||
<div style="width: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="justify_content_row_space_between" style="width: 102px; height: 102px; flex-direction: row; justify-content: space-between;">
|
||||
<div style="width: 10px;"></div>
|
||||
<div style="width: 10px;"></div>
|
||||
<div style="width: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="justify_content_row_space_around" style="width: 102px; height: 102px; flex-direction: row; justify-content: space-around;">
|
||||
<div style="width: 10px;"></div>
|
||||
<div style="width: 10px;"></div>
|
||||
<div style="width: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="justify_content_column_flex_start" style="width: 102px; height: 102px; justify-content: flex-start;">
|
||||
<div style="height: 10px;"></div>
|
||||
<div style="heigth: 10px;"></div>
|
||||
<div style="height: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="justify_content_column_flex_end" style="width: 102px; height: 102px; justify-content: flex-end;">
|
||||
<div style="height: 10px;"></div>
|
||||
<div style="height: 10px;"></div>
|
||||
<div style="height: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="justify_content_column_center" style="width: 102px; height: 102px; justify-content: center;">
|
||||
<div style="height: 10px;"></div>
|
||||
<div style="height: 10px;"></div>
|
||||
<div style="height: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="justify_content_column_space_between" style="width: 102px; height: 102px; justify-content: space-between;">
|
||||
<div style="height: 10px;"></div>
|
||||
<div style="height: 10px;"></div>
|
||||
<div style="height: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="justify_content_column_space_around" style="width: 102px; height: 102px; justify-content: space-around;">
|
||||
<div style="height: 10px;"></div>
|
||||
<div style="height: 10px;"></div>
|
||||
<div style="height: 10px;"></div>
|
||||
</div>
|
||||
*
|
||||
*/
|
||||
|
||||
package com.facebook.csslayout;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class CSSLayoutJustifyContentTest {
|
||||
@Test
|
||||
public void test_justify_content_row_flex_start() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setFlexDirection(CSSFlexDirection.ROW);
|
||||
root.setStyleWidth(102);
|
||||
root.setStyleHeight(102);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setStyleWidth(10);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final CSSNode root_child1 = new CSSNode();
|
||||
root_child1.setStyleWidth(10);
|
||||
root.addChildAt(root_child1, 1);
|
||||
|
||||
final CSSNode root_child2 = new CSSNode();
|
||||
root_child2.setStyleWidth(10);
|
||||
root.addChildAt(root_child2, 2);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(102, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(102, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(102, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(10, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(102, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(20, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(102, root_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(102, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(102, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(92, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(102, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(82, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(102, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(72, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(102, root_child2.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_justify_content_row_flex_end() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setFlexDirection(CSSFlexDirection.ROW);
|
||||
root.setJustifyContent(CSSJustify.FLEX_END);
|
||||
root.setStyleWidth(102);
|
||||
root.setStyleHeight(102);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setStyleWidth(10);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final CSSNode root_child1 = new CSSNode();
|
||||
root_child1.setStyleWidth(10);
|
||||
root.addChildAt(root_child1, 1);
|
||||
|
||||
final CSSNode root_child2 = new CSSNode();
|
||||
root_child2.setStyleWidth(10);
|
||||
root.addChildAt(root_child2, 2);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(102, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(102, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(72, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(102, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(82, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(102, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(92, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(102, root_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(102, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(102, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(20, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(102, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(10, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(102, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(102, root_child2.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_justify_content_row_center() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setFlexDirection(CSSFlexDirection.ROW);
|
||||
root.setJustifyContent(CSSJustify.CENTER);
|
||||
root.setStyleWidth(102);
|
||||
root.setStyleHeight(102);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setStyleWidth(10);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final CSSNode root_child1 = new CSSNode();
|
||||
root_child1.setStyleWidth(10);
|
||||
root.addChildAt(root_child1, 1);
|
||||
|
||||
final CSSNode root_child2 = new CSSNode();
|
||||
root_child2.setStyleWidth(10);
|
||||
root.addChildAt(root_child2, 2);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(102, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(102, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(36, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(102, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(46, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(102, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(56, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(102, root_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(102, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(102, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(56, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(102, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(46, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(102, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(36, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(102, root_child2.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_justify_content_row_space_between() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setFlexDirection(CSSFlexDirection.ROW);
|
||||
root.setJustifyContent(CSSJustify.SPACE_BETWEEN);
|
||||
root.setStyleWidth(102);
|
||||
root.setStyleHeight(102);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setStyleWidth(10);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final CSSNode root_child1 = new CSSNode();
|
||||
root_child1.setStyleWidth(10);
|
||||
root.addChildAt(root_child1, 1);
|
||||
|
||||
final CSSNode root_child2 = new CSSNode();
|
||||
root_child2.setStyleWidth(10);
|
||||
root.addChildAt(root_child2, 2);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(102, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(102, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(102, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(46, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(102, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(92, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(102, root_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(102, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(102, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(92, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(102, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(46, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(102, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(102, root_child2.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_justify_content_row_space_around() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setFlexDirection(CSSFlexDirection.ROW);
|
||||
root.setJustifyContent(CSSJustify.SPACE_AROUND);
|
||||
root.setStyleWidth(102);
|
||||
root.setStyleHeight(102);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setStyleWidth(10);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final CSSNode root_child1 = new CSSNode();
|
||||
root_child1.setStyleWidth(10);
|
||||
root.addChildAt(root_child1, 1);
|
||||
|
||||
final CSSNode root_child2 = new CSSNode();
|
||||
root_child2.setStyleWidth(10);
|
||||
root.addChildAt(root_child2, 2);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(102, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(102, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(12, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(102, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(46, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(102, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(80, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(102, root_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(102, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(102, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(80, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(102, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(46, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(102, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(12, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(102, root_child2.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_justify_content_column_flex_start() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setStyleWidth(102);
|
||||
root.setStyleHeight(102);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setStyleHeight(10);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final CSSNode root_child1 = new CSSNode();
|
||||
root.addChildAt(root_child1, 1);
|
||||
|
||||
final CSSNode root_child2 = new CSSNode();
|
||||
root_child2.setStyleHeight(10);
|
||||
root.addChildAt(root_child2, 2);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(102, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(102, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(102, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(10, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(102, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(0, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(10, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(102, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(102, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(102, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(102, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(10, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(102, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(0, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(10, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(102, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child2.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_justify_content_column_flex_end() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setJustifyContent(CSSJustify.FLEX_END);
|
||||
root.setStyleWidth(102);
|
||||
root.setStyleHeight(102);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setStyleHeight(10);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final CSSNode root_child1 = new CSSNode();
|
||||
root_child1.setStyleHeight(10);
|
||||
root.addChildAt(root_child1, 1);
|
||||
|
||||
final CSSNode root_child2 = new CSSNode();
|
||||
root_child2.setStyleHeight(10);
|
||||
root.addChildAt(root_child2, 2);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(102, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(102, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(72, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(102, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(82, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(102, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(92, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(102, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(102, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(102, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(72, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(102, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(82, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(102, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(92, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(102, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child2.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_justify_content_column_center() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setJustifyContent(CSSJustify.CENTER);
|
||||
root.setStyleWidth(102);
|
||||
root.setStyleHeight(102);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setStyleHeight(10);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final CSSNode root_child1 = new CSSNode();
|
||||
root_child1.setStyleHeight(10);
|
||||
root.addChildAt(root_child1, 1);
|
||||
|
||||
final CSSNode root_child2 = new CSSNode();
|
||||
root_child2.setStyleHeight(10);
|
||||
root.addChildAt(root_child2, 2);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(102, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(102, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(36, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(102, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(46, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(102, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(56, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(102, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(102, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(102, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(36, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(102, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(46, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(102, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(56, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(102, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child2.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_justify_content_column_space_between() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setJustifyContent(CSSJustify.SPACE_BETWEEN);
|
||||
root.setStyleWidth(102);
|
||||
root.setStyleHeight(102);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setStyleHeight(10);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final CSSNode root_child1 = new CSSNode();
|
||||
root_child1.setStyleHeight(10);
|
||||
root.addChildAt(root_child1, 1);
|
||||
|
||||
final CSSNode root_child2 = new CSSNode();
|
||||
root_child2.setStyleHeight(10);
|
||||
root.addChildAt(root_child2, 2);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(102, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(102, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(102, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(46, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(102, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(92, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(102, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(102, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(102, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(102, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(46, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(102, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(92, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(102, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child2.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_justify_content_column_space_around() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setJustifyContent(CSSJustify.SPACE_AROUND);
|
||||
root.setStyleWidth(102);
|
||||
root.setStyleHeight(102);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setStyleHeight(10);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final CSSNode root_child1 = new CSSNode();
|
||||
root_child1.setStyleHeight(10);
|
||||
root.addChildAt(root_child1, 1);
|
||||
|
||||
final CSSNode root_child2 = new CSSNode();
|
||||
root_child2.setStyleHeight(10);
|
||||
root.addChildAt(root_child2, 2);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(102, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(102, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(12, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(102, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(46, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(102, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(80, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(102, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(102, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(102, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(12, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(102, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(46, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(102, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(80, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(102, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child2.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
}
|
467
java/tests/com/facebook/csslayout/CSSLayoutMarginTest.java
Normal file
467
java/tests/com/facebook/csslayout/CSSLayoutMarginTest.java
Normal file
@@ -0,0 +1,467 @@
|
||||
/**
|
||||
* Copyright (c) 2014-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @Generated by gentest/gentest.sh with the following input
|
||||
*
|
||||
<div id="margin_start" style="width: 100px; height: 100px; flex-direction: row;">
|
||||
<div style="width: 10px; margin-start: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="margin_top" style="width: 100px; height: 100px;">
|
||||
<div style="height: 10px; margin-top: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="margin_end" style="width: 100px; height: 100px; flex-direction: row; justify-content: flex-end;">
|
||||
<div style="width: 10px; margin-end: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="margin_bottom" style="width: 100px; height: 100px; justify-content: flex-end;">
|
||||
<div style="height: 10px; margin-bottom: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="margin_and_flex_row" style="width: 100px; height: 100px; flex-direction: row;">
|
||||
<div style="margin-start: 10px; margin-end; 10px; flex-grow: 1;"></div>
|
||||
</div>
|
||||
|
||||
<div id="margin_and_flex_column" style="width: 100px; height: 100px;">
|
||||
<div style="margin-top: 10px; margin-bottom; 10px; flex-grow: 1;"></div>
|
||||
</div>
|
||||
|
||||
<div id="margin_and_stretch_row" style="width: 100px; height: 100px; flex-direction: row;">
|
||||
<div style="margin-top: 10px; margin-bottom; 10px; flex-grow: 1;"></div>
|
||||
</div>
|
||||
|
||||
<div id="margin_and_stretch_column" style="width: 100px; height: 100px;">
|
||||
<div style="margin-start: 10px; margin-end; 10px; flex-grow: 1;"></div>
|
||||
</div>
|
||||
|
||||
<div id="margin_with_sibling_row" style="width: 100px; height: 100px; flex-direction: row;">
|
||||
<div style="margin-end; 10px; flex-grow: 1;"></div>
|
||||
<div style="flex-grow: 1;"></div>
|
||||
</div>
|
||||
|
||||
<div id="margin_with_sibling_column" style="width: 100px; height: 100px;">
|
||||
<div style="margin-bottom; 10px; flex-grow: 1;"></div>
|
||||
<div style="flex-grow: 1;"></div>
|
||||
</div>
|
||||
*
|
||||
*/
|
||||
|
||||
package com.facebook.csslayout;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class CSSLayoutMarginTest {
|
||||
@Test
|
||||
public void test_margin_start() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setFlexDirection(CSSFlexDirection.ROW);
|
||||
root.setStyleWidth(100);
|
||||
root.setStyleHeight(100);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setMargin(Spacing.START, 10);
|
||||
root_child0.setStyleWidth(10);
|
||||
root.addChildAt(root_child0, 0);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(10, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(80, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root_child0.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_margin_top() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setStyleWidth(100);
|
||||
root.setStyleHeight(100);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setMargin(Spacing.TOP, 10);
|
||||
root_child0.setStyleHeight(10);
|
||||
root.addChildAt(root_child0, 0);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_margin_end() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setFlexDirection(CSSFlexDirection.ROW);
|
||||
root.setJustifyContent(CSSJustify.FLEX_END);
|
||||
root.setStyleWidth(100);
|
||||
root.setStyleHeight(100);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setMargin(Spacing.END, 10);
|
||||
root_child0.setStyleWidth(10);
|
||||
root.addChildAt(root_child0, 0);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(80, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(10, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root_child0.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_margin_bottom() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setJustifyContent(CSSJustify.FLEX_END);
|
||||
root.setStyleWidth(100);
|
||||
root.setStyleHeight(100);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setMargin(Spacing.BOTTOM, 10);
|
||||
root_child0.setStyleHeight(10);
|
||||
root.addChildAt(root_child0, 0);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(80, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(80, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_margin_and_flex_row() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setFlexDirection(CSSFlexDirection.ROW);
|
||||
root.setStyleWidth(100);
|
||||
root.setStyleHeight(100);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setFlexGrow(1);
|
||||
root_child0.setMargin(Spacing.START, 10);
|
||||
root.addChildAt(root_child0, 0);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(10, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(90, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(90, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root_child0.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_margin_and_flex_column() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setStyleWidth(100);
|
||||
root.setStyleHeight(100);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setFlexGrow(1);
|
||||
root_child0.setMargin(Spacing.TOP, 10);
|
||||
root.addChildAt(root_child0, 0);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(90, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(90, root_child0.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_margin_and_stretch_row() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setFlexDirection(CSSFlexDirection.ROW);
|
||||
root.setStyleWidth(100);
|
||||
root.setStyleHeight(100);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setFlexGrow(1);
|
||||
root_child0.setMargin(Spacing.TOP, 10);
|
||||
root.addChildAt(root_child0, 0);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(90, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(90, root_child0.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_margin_and_stretch_column() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setStyleWidth(100);
|
||||
root.setStyleHeight(100);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setFlexGrow(1);
|
||||
root_child0.setMargin(Spacing.START, 10);
|
||||
root.addChildAt(root_child0, 0);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(10, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(90, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(90, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root_child0.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_margin_with_sibling_row() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setFlexDirection(CSSFlexDirection.ROW);
|
||||
root.setStyleWidth(100);
|
||||
root.setStyleHeight(100);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setFlexGrow(1);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final CSSNode root_child1 = new CSSNode();
|
||||
root_child1.setFlexGrow(1);
|
||||
root.addChildAt(root_child1, 1);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(50, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(50, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root_child1.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_margin_with_sibling_column() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setStyleWidth(100);
|
||||
root.setStyleHeight(100);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setFlexGrow(1);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final CSSNode root_child1 = new CSSNode();
|
||||
root_child1.setFlexGrow(1);
|
||||
root.addChildAt(root_child1, 1);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(50, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(50, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(50, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(50, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(50, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(50, root_child1.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,378 @@
|
||||
/**
|
||||
* Copyright (c) 2014-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @Generated by gentest/gentest.sh with the following input
|
||||
*
|
||||
<div id="max_width" style="width: 100px; height: 100px;">
|
||||
<div style="height: 10px; max-width: 50px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="max_height" style="width: 100px; height: 100px; flex-direction: row;">
|
||||
<div style="width: 10px; max-height: 50px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="min_height" style="width: 100px; height: 100px;">
|
||||
<div style="flex-grow: 1; min-height: 60px;"></div>
|
||||
<div style="flex-grow: 1;"></div>
|
||||
</div>
|
||||
|
||||
<div id="min_width" style="width: 100px; height: 100px; flex-direction: row">
|
||||
<div style="flex-grow: 1; min-width: 60px;"></div>
|
||||
<div style="flex-grow: 1;"></div>
|
||||
</div>
|
||||
|
||||
<div id="justify_content_min_max" style="max-height: 200px; min-height: 100px; width: 100px; justify-content: center;">
|
||||
<div style="width: 60px; height: 60px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="align_items_min_max" style="max-width: 200px; min-width: 100px; height: 100px; align-items: center;">
|
||||
<div style="width: 60px; height: 60px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="justify_content_overflow_min_max" style="min-height: 100px; max-height: 110px; justify-content: center;">
|
||||
<div style="width: 50px; height: 50px;"></div>
|
||||
<div style="width: 50px; height: 50px;"></div>
|
||||
<div style="width: 50px; height: 50px;"></div>
|
||||
</div>
|
||||
*
|
||||
*/
|
||||
|
||||
package com.facebook.csslayout;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class CSSLayoutMinMaxDimensionTest {
|
||||
@Test
|
||||
public void test_max_width() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setStyleWidth(100);
|
||||
root.setStyleHeight(100);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setStyleMaxWidth(50);
|
||||
root_child0.setStyleHeight(10);
|
||||
root.addChildAt(root_child0, 0);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(50, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_max_height() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setFlexDirection(CSSFlexDirection.ROW);
|
||||
root.setStyleWidth(100);
|
||||
root.setStyleHeight(100);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setStyleWidth(10);
|
||||
root_child0.setStyleMaxHeight(50);
|
||||
root.addChildAt(root_child0, 0);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(50, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(90, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(50, root_child0.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_min_height() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setStyleWidth(100);
|
||||
root.setStyleHeight(100);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setFlexGrow(1);
|
||||
root_child0.setStyleMinHeight(60);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final CSSNode root_child1 = new CSSNode();
|
||||
root_child1.setFlexGrow(1);
|
||||
root.addChildAt(root_child1, 1);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(80, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(80, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(20, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(80, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(80, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(20, root_child1.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_min_width() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setFlexDirection(CSSFlexDirection.ROW);
|
||||
root.setStyleWidth(100);
|
||||
root.setStyleHeight(100);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setFlexGrow(1);
|
||||
root_child0.setStyleMinWidth(60);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final CSSNode root_child1 = new CSSNode();
|
||||
root_child1.setFlexGrow(1);
|
||||
root.addChildAt(root_child1, 1);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(80, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(80, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(20, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(20, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(80, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(20, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root_child1.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_justify_content_min_max() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setJustifyContent(CSSJustify.CENTER);
|
||||
root.setStyleWidth(100);
|
||||
root.setStyleMinHeight(100);
|
||||
root.setStyleMaxHeight(200);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setStyleWidth(60);
|
||||
root_child0.setStyleHeight(60);
|
||||
root.addChildAt(root_child0, 0);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(20, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(60, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(60, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(40, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(20, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(60, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(60, root_child0.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_align_items_min_max() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setAlignItems(CSSAlign.CENTER);
|
||||
root.setStyleMinWidth(100);
|
||||
root.setStyleMaxWidth(200);
|
||||
root.setStyleHeight(100);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setStyleWidth(60);
|
||||
root_child0.setStyleHeight(60);
|
||||
root.addChildAt(root_child0, 0);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(20, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(60, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(60, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(20, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(60, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(60, root_child0.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_justify_content_overflow_min_max() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setJustifyContent(CSSJustify.CENTER);
|
||||
root.setStyleMinHeight(100);
|
||||
root.setStyleMaxHeight(110);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setStyleWidth(50);
|
||||
root_child0.setStyleHeight(50);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final CSSNode root_child1 = new CSSNode();
|
||||
root_child1.setStyleWidth(50);
|
||||
root_child1.setStyleHeight(50);
|
||||
root.addChildAt(root_child1, 1);
|
||||
|
||||
final CSSNode root_child2 = new CSSNode();
|
||||
root_child2.setStyleWidth(50);
|
||||
root_child2.setStyleHeight(50);
|
||||
root.addChildAt(root_child2, 2);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(110, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(-20, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(50, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(30, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(50, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(80, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(50, root_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(110, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(-20, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(50, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(30, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(50, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(80, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(50, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(50, root_child2.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
}
|
227
java/tests/com/facebook/csslayout/CSSLayoutPaddingTest.java
Normal file
227
java/tests/com/facebook/csslayout/CSSLayoutPaddingTest.java
Normal file
@@ -0,0 +1,227 @@
|
||||
/**
|
||||
* Copyright (c) 2014-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @Generated by gentest/gentest.sh with the following input
|
||||
*
|
||||
<div id="padding_no_size" style="padding: 10px;">
|
||||
</div>
|
||||
|
||||
<div id="padding_container_match_child" style="padding: 10px;">
|
||||
<div style="width: 10px; height: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="padding_flex_child" style="width: 100px; height: 100px; padding: 10px;">
|
||||
<div style="width: 10px; flex-grow:1"></div>
|
||||
</div>
|
||||
|
||||
<div id="padding_stretch_child" style="width: 100px; height: 100px; padding: 10px;">
|
||||
<div style="height: 10px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="padding_center_child" style="width: 100px; height: 100px; padding-start: 10px; padding-top: 10; padding-end: 20px; padding-bottom: 20px; align-items: center; justify-content: center;">
|
||||
<div style="height: 10px; width: 10px;"></div>
|
||||
</div>
|
||||
*
|
||||
*/
|
||||
|
||||
package com.facebook.csslayout;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class CSSLayoutPaddingTest {
|
||||
@Test
|
||||
public void test_padding_no_size() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setPadding(Spacing.LEFT, 10);
|
||||
root.setPadding(Spacing.TOP, 10);
|
||||
root.setPadding(Spacing.RIGHT, 10);
|
||||
root.setPadding(Spacing.BOTTOM, 10);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(20, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(20, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(20, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(20, root.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_padding_container_match_child() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setPadding(Spacing.LEFT, 10);
|
||||
root.setPadding(Spacing.TOP, 10);
|
||||
root.setPadding(Spacing.RIGHT, 10);
|
||||
root.setPadding(Spacing.BOTTOM, 10);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setStyleWidth(10);
|
||||
root_child0.setStyleHeight(10);
|
||||
root.addChildAt(root_child0, 0);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(30, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(30, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(10, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(30, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(30, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(10, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_padding_flex_child() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setPadding(Spacing.LEFT, 10);
|
||||
root.setPadding(Spacing.TOP, 10);
|
||||
root.setPadding(Spacing.RIGHT, 10);
|
||||
root.setPadding(Spacing.BOTTOM, 10);
|
||||
root.setStyleWidth(100);
|
||||
root.setStyleHeight(100);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setFlexGrow(1);
|
||||
root_child0.setStyleWidth(10);
|
||||
root.addChildAt(root_child0, 0);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(10, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(80, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(80, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(80, root_child0.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_padding_stretch_child() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setPadding(Spacing.LEFT, 10);
|
||||
root.setPadding(Spacing.TOP, 10);
|
||||
root.setPadding(Spacing.RIGHT, 10);
|
||||
root.setPadding(Spacing.BOTTOM, 10);
|
||||
root.setStyleWidth(100);
|
||||
root.setStyleHeight(100);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setStyleHeight(10);
|
||||
root.addChildAt(root_child0, 0);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(10, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(80, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(10, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(80, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_padding_center_child() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setJustifyContent(CSSJustify.CENTER);
|
||||
root.setAlignItems(CSSAlign.CENTER);
|
||||
root.setPadding(Spacing.START, 10);
|
||||
root.setPadding(Spacing.END, 20);
|
||||
root.setPadding(Spacing.BOTTOM, 20);
|
||||
root.setStyleWidth(100);
|
||||
root.setStyleHeight(100);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setStyleWidth(10);
|
||||
root_child0.setStyleHeight(10);
|
||||
root.addChildAt(root_child0, 0);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(40, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(35, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(50, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(35, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10, root_child0.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user