Skip to content

Instantly share code, notes, and snippets.

@javache
Created March 22, 2016 00:02
Show Gist options
  • Save javache/f38f48b85d497da832ec to your computer and use it in GitHub Desktop.
Save javache/f38f48b85d497da832ec to your computer and use it in GitHub Desktop.
commit e391fbe76e2fcb70c38b2aa0d7528bcc3cf9a316
Author: Pieter De Baets <[email protected]>
Date: Tue Mar 22 00:01:59 2016 +0000
Failing test
diff --git a/dist/css-layout.jar b/dist/css-layout.jar
index c9a83c8..50bfed4 100644
Binary files a/dist/css-layout.jar and b/dist/css-layout.jar differ
diff --git a/src/__tests__/Layout-test.c b/src/__tests__/Layout-test.c
index fe31e68..fd11bf2 100644
--- a/src/__tests__/Layout-test.c
+++ b/src/__tests__/Layout-test.c
@@ -7921,6 +7921,94 @@ int main()
{
css_node_t *node_0 = root_node;
node_0->style.flex_direction = CSS_FLEX_DIRECTION_ROW;
+ init_css_node_children(node_0, 2);
+ {
+ css_node_t *node_1;
+ node_1 = node_0->get_child(node_0->context, 0);
+ init_css_node_children(node_1, 1);
+ {
+ css_node_t *node_2;
+ node_2 = node_1->get_child(node_1->context, 0);
+ node_2->style.dimensions[CSS_WIDTH] = 100;
+ node_2->style.dimensions[CSS_HEIGHT] = 100;
+ }
+ node_1 = node_0->get_child(node_0->context, 1);
+ node_1->style.dimensions[CSS_WIDTH] = 100;
+ init_css_node_children(node_1, 1);
+ {
+ css_node_t *node_2;
+ node_2 = node_1->get_child(node_1->context, 0);
+ node_2->style.flex_direction = CSS_FLEX_DIRECTION_COLUMN;
+ node_2->style.align_items = CSS_ALIGN_CENTER;
+ init_css_node_children(node_2, 1);
+ {
+ css_node_t *node_3;
+ node_3 = node_2->get_child(node_2->context, 0);
+ node_3->style.dimensions[CSS_WIDTH] = 50;
+ node_3->style.dimensions[CSS_HEIGHT] = 50;
+ }
+ }
+ }
+ }
+
+ css_node_t *root_layout = new_test_css_node();
+ {
+ css_node_t *node_0 = root_layout;
+ node_0->layout.position[CSS_TOP] = 0;
+ node_0->layout.position[CSS_LEFT] = 0;
+ node_0->layout.dimensions[CSS_WIDTH] = 200;
+ node_0->layout.dimensions[CSS_HEIGHT] = 100;
+ init_css_node_children(node_0, 2);
+ {
+ css_node_t *node_1;
+ node_1 = node_0->get_child(node_0->context, 0);
+ node_1->layout.position[CSS_TOP] = 0;
+ node_1->layout.position[CSS_LEFT] = 0;
+ node_1->layout.dimensions[CSS_WIDTH] = 100;
+ node_1->layout.dimensions[CSS_HEIGHT] = 100;
+ init_css_node_children(node_1, 1);
+ {
+ css_node_t *node_2;
+ node_2 = node_1->get_child(node_1->context, 0);
+ node_2->layout.position[CSS_TOP] = 0;
+ node_2->layout.position[CSS_LEFT] = 0;
+ node_2->layout.dimensions[CSS_WIDTH] = 100;
+ node_2->layout.dimensions[CSS_HEIGHT] = 100;
+ }
+ node_1 = node_0->get_child(node_0->context, 1);
+ node_1->layout.position[CSS_TOP] = 0;
+ node_1->layout.position[CSS_LEFT] = 100;
+ node_1->layout.dimensions[CSS_WIDTH] = 100;
+ node_1->layout.dimensions[CSS_HEIGHT] = 100;
+ init_css_node_children(node_1, 1);
+ {
+ css_node_t *node_2;
+ node_2 = node_1->get_child(node_1->context, 0);
+ node_2->layout.position[CSS_TOP] = 0;
+ node_2->layout.position[CSS_LEFT] = 0;
+ node_2->layout.dimensions[CSS_WIDTH] = 100;
+ node_2->layout.dimensions[CSS_HEIGHT] = 50;
+ init_css_node_children(node_2, 1);
+ {
+ css_node_t *node_3;
+ node_3 = node_2->get_child(node_2->context, 0);
+ node_3->layout.position[CSS_TOP] = 0;
+ node_3->layout.position[CSS_LEFT] = 25;
+ node_3->layout.dimensions[CSS_WIDTH] = 50;
+ node_3->layout.dimensions[CSS_HEIGHT] = 50;
+ }
+ }
+ }
+ }
+
+ test("should center tems correctly inside a stretched layout", root_node, root_layout);
+ }
+
+ {
+ css_node_t *root_node = new_test_css_node();
+ {
+ css_node_t *node_0 = root_node;
+ node_0->style.flex_direction = CSS_FLEX_DIRECTION_ROW;
node_0->style.align_content = CSS_ALIGN_STRETCH;
node_0->style.align_items = CSS_ALIGN_FLEX_START;
node_0->style.flex_wrap = CSS_WRAP;
diff --git a/src/__tests__/Layout-test.js b/src/__tests__/Layout-test.js
index aed51c5..a32b057 100755
--- a/src/__tests__/Layout-test.js
+++ b/src/__tests__/Layout-test.js
@@ -41,7 +41,6 @@ describe('Javascript Only', function() {
});
});
-
describe('Layout', function() {
it('should layout a single node with width and height', function() {
testLayout({
@@ -2459,6 +2458,31 @@ describe('Layout', function() {
]}
);
});
+
+ it('should center tems correctly inside a stretched layout', function() {
+ testLayout(
+ {style: {flexDirection: 'row'}, children: [
+ {style: {}, children: [
+ {style: {width: 100, height: 100}}
+ ]},
+ {style: {width: 100}, children: [
+ {style: {flexDirection: 'column', alignItems: 'center'}, children: [
+ {style: {width: 50, height: 50}},
+ ]},
+ ]},
+ ]},
+ {width: 200, height: 100, top: 0, left: 0, children: [
+ {width: 100, height: 100, top: 0, left: 0, children: [
+ {width: 100, height: 100, top: 0, left: 0}
+ ]},
+ {width: 100, height: 100, top: 0, left: 100, children: [
+ {width: 100, height: 50, top: 0, left: 0, children: [
+ {width: 50, height: 50, top: 0, left: 25}
+ ]},
+ ]},
+ ]}
+ );
+ });
});
describe('Layout alignContent', function() {
diff --git a/src/csharp/Facebook.CSSLayout.Tests/LayoutEngineTest.cs b/src/csharp/Facebook.CSSLayout.Tests/LayoutEngineTest.cs
index 3b81ed5..a3b0d5f 100644
--- a/src/csharp/Facebook.CSSLayout.Tests/LayoutEngineTest.cs
+++ b/src/csharp/Facebook.CSSLayout.Tests/LayoutEngineTest.cs
@@ -8392,6 +8392,96 @@ public class LayoutEngineTest
{
TestCSSNode node_0 = root_node;
node_0.style.flexDirection = CSSFlexDirection.Row;
+ addChildren(node_0, 2);
+ {
+ TestCSSNode node_1;
+ node_1 = node_0.getChildAt(0);
+ addChildren(node_1, 1);
+ {
+ TestCSSNode node_2;
+ node_2 = node_1.getChildAt(0);
+ node_2.style.dimensions[DIMENSION_WIDTH] = 100;
+ node_2.style.dimensions[DIMENSION_HEIGHT] = 100;
+ }
+ node_1 = node_0.getChildAt(1);
+ node_1.style.dimensions[DIMENSION_WIDTH] = 100;
+ addChildren(node_1, 1);
+ {
+ TestCSSNode node_2;
+ node_2 = node_1.getChildAt(0);
+ node_2.style.flexDirection = CSSFlexDirection.Column;
+ node_2.style.alignItems = CSSAlign.Center;
+ addChildren(node_2, 1);
+ {
+ TestCSSNode node_3;
+ node_3 = node_2.getChildAt(0);
+ node_3.style.dimensions[DIMENSION_WIDTH] = 50;
+ node_3.style.dimensions[DIMENSION_HEIGHT] = 50;
+ }
+ }
+ }
+ }
+
+ TestCSSNode root_layout = new TestCSSNode();
+ {
+ TestCSSNode node_0 = root_layout;
+ node_0.layout.position[POSITION_TOP] = 0;
+ node_0.layout.position[POSITION_LEFT] = 0;
+ node_0.layout.dimensions[DIMENSION_WIDTH] = 200;
+ node_0.layout.dimensions[DIMENSION_HEIGHT] = 100;
+ addChildren(node_0, 2);
+ {
+ TestCSSNode node_1;
+ node_1 = node_0.getChildAt(0);
+ node_1.layout.position[POSITION_TOP] = 0;
+ node_1.layout.position[POSITION_LEFT] = 0;
+ node_1.layout.dimensions[DIMENSION_WIDTH] = 100;
+ node_1.layout.dimensions[DIMENSION_HEIGHT] = 100;
+ addChildren(node_1, 1);
+ {
+ TestCSSNode node_2;
+ node_2 = node_1.getChildAt(0);
+ node_2.layout.position[POSITION_TOP] = 0;
+ node_2.layout.position[POSITION_LEFT] = 0;
+ node_2.layout.dimensions[DIMENSION_WIDTH] = 100;
+ node_2.layout.dimensions[DIMENSION_HEIGHT] = 100;
+ }
+ node_1 = node_0.getChildAt(1);
+ node_1.layout.position[POSITION_TOP] = 0;
+ node_1.layout.position[POSITION_LEFT] = 100;
+ node_1.layout.dimensions[DIMENSION_WIDTH] = 100;
+ node_1.layout.dimensions[DIMENSION_HEIGHT] = 100;
+ addChildren(node_1, 1);
+ {
+ TestCSSNode node_2;
+ node_2 = node_1.getChildAt(0);
+ node_2.layout.position[POSITION_TOP] = 0;
+ node_2.layout.position[POSITION_LEFT] = 0;
+ node_2.layout.dimensions[DIMENSION_WIDTH] = 100;
+ node_2.layout.dimensions[DIMENSION_HEIGHT] = 50;
+ addChildren(node_2, 1);
+ {
+ TestCSSNode node_3;
+ node_3 = node_2.getChildAt(0);
+ node_3.layout.position[POSITION_TOP] = 0;
+ node_3.layout.position[POSITION_LEFT] = 25;
+ node_3.layout.dimensions[DIMENSION_WIDTH] = 50;
+ node_3.layout.dimensions[DIMENSION_HEIGHT] = 50;
+ }
+ }
+ }
+ }
+
+ test("should center tems correctly inside a stretched layout", root_node, root_layout);
+ }
+
+ [Test]
+ public void TestCase188()
+ {
+ TestCSSNode root_node = new TestCSSNode();
+ {
+ TestCSSNode node_0 = root_node;
+ node_0.style.flexDirection = CSSFlexDirection.Row;
node_0.style.alignContent = CSSAlign.Stretch;
node_0.style.alignItems = CSSAlign.FlexStart;
node_0.style.flexWrap = CSSWrap.Wrap;
diff --git a/src/java/tests/com/facebook/csslayout/LayoutEngineTest.java b/src/java/tests/com/facebook/csslayout/LayoutEngineTest.java
index 66788c5..12a47f6 100644
--- a/src/java/tests/com/facebook/csslayout/LayoutEngineTest.java
+++ b/src/java/tests/com/facebook/csslayout/LayoutEngineTest.java
@@ -8395,6 +8395,96 @@ public class LayoutEngineTest {
{
TestCSSNode node_0 = root_node;
node_0.style.flexDirection = CSSFlexDirection.ROW;
+ addChildren(node_0, 2);
+ {
+ TestCSSNode node_1;
+ node_1 = node_0.getChildAt(0);
+ addChildren(node_1, 1);
+ {
+ TestCSSNode node_2;
+ node_2 = node_1.getChildAt(0);
+ node_2.style.dimensions[DIMENSION_WIDTH] = 100;
+ node_2.style.dimensions[DIMENSION_HEIGHT] = 100;
+ }
+ node_1 = node_0.getChildAt(1);
+ node_1.style.dimensions[DIMENSION_WIDTH] = 100;
+ addChildren(node_1, 1);
+ {
+ TestCSSNode node_2;
+ node_2 = node_1.getChildAt(0);
+ node_2.style.flexDirection = CSSFlexDirection.COLUMN;
+ node_2.style.alignItems = CSSAlign.CENTER;
+ addChildren(node_2, 1);
+ {
+ TestCSSNode node_3;
+ node_3 = node_2.getChildAt(0);
+ node_3.style.dimensions[DIMENSION_WIDTH] = 50;
+ node_3.style.dimensions[DIMENSION_HEIGHT] = 50;
+ }
+ }
+ }
+ }
+
+ TestCSSNode root_layout = new TestCSSNode();
+ {
+ TestCSSNode node_0 = root_layout;
+ node_0.layout.position[POSITION_TOP] = 0;
+ node_0.layout.position[POSITION_LEFT] = 0;
+ node_0.layout.dimensions[DIMENSION_WIDTH] = 200;
+ node_0.layout.dimensions[DIMENSION_HEIGHT] = 100;
+ addChildren(node_0, 2);
+ {
+ TestCSSNode node_1;
+ node_1 = node_0.getChildAt(0);
+ node_1.layout.position[POSITION_TOP] = 0;
+ node_1.layout.position[POSITION_LEFT] = 0;
+ node_1.layout.dimensions[DIMENSION_WIDTH] = 100;
+ node_1.layout.dimensions[DIMENSION_HEIGHT] = 100;
+ addChildren(node_1, 1);
+ {
+ TestCSSNode node_2;
+ node_2 = node_1.getChildAt(0);
+ node_2.layout.position[POSITION_TOP] = 0;
+ node_2.layout.position[POSITION_LEFT] = 0;
+ node_2.layout.dimensions[DIMENSION_WIDTH] = 100;
+ node_2.layout.dimensions[DIMENSION_HEIGHT] = 100;
+ }
+ node_1 = node_0.getChildAt(1);
+ node_1.layout.position[POSITION_TOP] = 0;
+ node_1.layout.position[POSITION_LEFT] = 100;
+ node_1.layout.dimensions[DIMENSION_WIDTH] = 100;
+ node_1.layout.dimensions[DIMENSION_HEIGHT] = 100;
+ addChildren(node_1, 1);
+ {
+ TestCSSNode node_2;
+ node_2 = node_1.getChildAt(0);
+ node_2.layout.position[POSITION_TOP] = 0;
+ node_2.layout.position[POSITION_LEFT] = 0;
+ node_2.layout.dimensions[DIMENSION_WIDTH] = 100;
+ node_2.layout.dimensions[DIMENSION_HEIGHT] = 50;
+ addChildren(node_2, 1);
+ {
+ TestCSSNode node_3;
+ node_3 = node_2.getChildAt(0);
+ node_3.layout.position[POSITION_TOP] = 0;
+ node_3.layout.position[POSITION_LEFT] = 25;
+ node_3.layout.dimensions[DIMENSION_WIDTH] = 50;
+ node_3.layout.dimensions[DIMENSION_HEIGHT] = 50;
+ }
+ }
+ }
+ }
+
+ test("should center tems correctly inside a stretched layout", root_node, root_layout);
+ }
+
+ @Test
+ public void testCase188()
+ {
+ TestCSSNode root_node = new TestCSSNode();
+ {
+ TestCSSNode node_0 = root_node;
+ node_0.style.flexDirection = CSSFlexDirection.ROW;
node_0.style.alignContent = CSSAlign.STRETCH;
node_0.style.alignItems = CSSAlign.FLEX_START;
node_0.style.flexWrap = CSSWrap.WRAP;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment