diff --git a/gentest/gentest.js b/gentest/gentest.js index 9ad86df8..cd18d04c 100755 --- a/gentest/gentest.js +++ b/gentest/gentest.js @@ -8,10 +8,10 @@ */ window.onload = function() { - printTest(document.body.children[0], calculateTree(document.body.children[0])); + printTest(document.body.children[0], document.body.children[1], document.body.children[2]); } -function printTest(rootNode, layoutTree) { +function printTest(LTRContainer, RTLContainer, genericContainer) { var lines = [ '/**', ' * Copyright (c) 2014-present, Facebook, Inc.', @@ -29,7 +29,7 @@ function printTest(rootNode, layoutTree) { lines.push(' *'); var indentation = 0; - lines.push(rootNode.innerHTML.split('\n').map(function(line) { + lines.push(genericContainer.innerHTML.split('\n').map(function(line) { return line.trim(); }).filter(function(line) { return line.length > 0 && line !== '
'; @@ -62,17 +62,29 @@ function printTest(rootNode, layoutTree) { return curr + '\n' + prev; })); - for (var i = 0; i < layoutTree.length - 1; i++) { - lines.push('TEST(CSSLayoutTest, ' + layoutTree[i].name + ') {'); + var LTRLayoutTree = calculateTree(LTRContainer); + var RTLLayoutTree = calculateTree(RTLContainer); + var genericLayoutTree = calculateTree(genericContainer); - lines.push(' ' + setupTestTree(layoutTree[i], 'root', null).reduce(function(curr, prev) { + for (var i = 0; i < genericLayoutTree.length; i++) { + lines.push('TEST(CSSLayoutTest, ' + genericLayoutTree[i].name + ') {'); + + lines.push(' ' + setupTestTree(LTRLayoutTree[i], genericLayoutTree[i], 'root', null).reduce(function(curr, prev) { return curr + '\n ' + prev; })); lines.push(' CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);'); lines.push(''); - lines.push(' ' + assertTestTree(layoutTree[i], 'root', null).reduce(function(curr, prev) { + lines.push(' ' + assertTestTree(LTRLayoutTree[i], 'root', null).reduce(function(curr, prev) { + return curr + '\n ' + prev; + })); + lines.push(''); + + lines.push(' CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL);'); + lines.push(''); + + lines.push(' ' + assertTestTree(RTLLayoutTree[i], 'root', null).reduce(function(curr, prev) { return curr + '\n ' + prev; })); @@ -100,7 +112,7 @@ function assertTestTree(node, nodeName, parentName) { return lines; } -function setupTestTree(node, nodeName, parentName, index) { +function setupTestTree(node, genericNode, nodeName, parentName, index) { var lines = [ 'const CSSNodeRef ' + nodeName + ' = CSSNodeNew();', ]; @@ -167,64 +179,104 @@ function setupTestTree(node, nodeName, parentName, index) { pixelValue(node.style[style]) + ');'); break; case 'left': - lines.push('CSSNodeStyleSetPosition(' + nodeName + ', CSSEdgeLeft, ' + - pixelValue(node.style[style]) + ');'); + if (genericNode.rawStyle.indexOf('start:') >= 0) { + lines.push('CSSNodeStyleSetPosition(' + nodeName + ', CSSEdgeStart, ' + + pixelValue(node.style[style]) + ');'); + } else { + lines.push('CSSNodeStyleSetPosition(' + nodeName + ', CSSEdgeLeft, ' + + pixelValue(node.style[style]) + ');'); + } break; case 'top': lines.push('CSSNodeStyleSetPosition(' + nodeName + ', CSSEdgeTop, ' + pixelValue(node.style[style]) + ');'); break; case 'right': - lines.push('CSSNodeStyleSetPosition(' + nodeName + ', CSSEdgeRight, ' + - pixelValue(node.style[style]) + ');'); + if (genericNode.rawStyle.indexOf('end:') >= 0) { + lines.push('CSSNodeStyleSetPosition(' + nodeName + ', CSSEdgeEnd, ' + + pixelValue(node.style[style]) + ');'); + } else { + lines.push('CSSNodeStyleSetPosition(' + nodeName + ', CSSEdgeRight, ' + + pixelValue(node.style[style]) + ');'); + } break; case 'bottom': lines.push('CSSNodeStyleSetPosition(' + nodeName + ', CSSEdgeBottom, ' + pixelValue(node.style[style]) + ');'); break; case 'margin-left': - lines.push('CSSNodeStyleSetMargin(' + nodeName + ', CSSEdgeLeft, ' + - pixelValue(node.style[style]) + ');'); + if (genericNode.rawStyle.indexOf('margin-start:') >= 0) { + lines.push('CSSNodeStyleSetMargin(' + nodeName + ', CSSEdgeStart, ' + + pixelValue(node.style[style]) + ');'); + } else { + lines.push('CSSNodeStyleSetMargin(' + nodeName + ', CSSEdgeLeft, ' + + pixelValue(node.style[style]) + ');'); + } break; case 'margin-top': lines.push('CSSNodeStyleSetMargin(' + nodeName + ', CSSEdgeTop, ' + pixelValue(node.style[style]) + ');'); break; case 'margin-right': - lines.push('CSSNodeStyleSetMargin(' + nodeName + ', CSSEdgeRight, ' + - pixelValue(node.style[style]) + ');'); + if (genericNode.rawStyle.indexOf('margin-end:') >= 0) { + lines.push('CSSNodeStyleSetMargin(' + nodeName + ', CSSEdgeEnd, ' + + pixelValue(node.style[style]) + ');'); + } else { + lines.push('CSSNodeStyleSetMargin(' + nodeName + ', CSSEdgeRight, ' + + pixelValue(node.style[style]) + ');'); + } break; case 'margin-bottom': lines.push('CSSNodeStyleSetMargin(' + nodeName + ', CSSEdgeBottom, ' + pixelValue(node.style[style]) + ');'); break; case 'padding-left': - lines.push('CSSNodeStyleSetPadding(' + nodeName + ', CSSEdgeLeft, ' + - pixelValue(node.style[style]) + ');'); + if (genericNode.rawStyle.indexOf('padding-start:') >= 0) { + lines.push('CSSNodeStyleSetPadding(' + nodeName + ', CSSEdgeStart, ' + + pixelValue(node.style[style]) + ');'); + } else { + lines.push('CSSNodeStyleSetPadding(' + nodeName + ', CSSEdgeLeft, ' + + pixelValue(node.style[style]) + ');'); + } break; case 'padding-top': lines.push('CSSNodeStyleSetPadding(' + nodeName + ', CSSEdgeTop, ' + pixelValue(node.style[style]) + ');'); break; case 'padding-right': - lines.push('CSSNodeStyleSetPadding(' + nodeName + ', CSSEdgeRight, ' + - pixelValue(node.style[style]) + ');'); + if (genericNode.rawStyle.indexOf('padding-end:') >= 0) { + lines.push('CSSNodeStyleSetPadding(' + nodeName + ', CSSEdgeEnd, ' + + pixelValue(node.style[style]) + ');'); + } else { + lines.push('CSSNodeStyleSetPadding(' + nodeName + ', CSSEdgeRight, ' + + pixelValue(node.style[style]) + ');'); + } break; case 'padding-bottom': lines.push('CSSNodeStyleSetPadding(' + nodeName + ', CSSEdgeBottom, ' + pixelValue(node.style[style]) + ');'); break; case 'border-left-width': - lines.push('CSSNodeStyleSetBorder(' + nodeName + ', CSSEdgeLeft, ' + - pixelValue(node.style[style]) + ');'); + if (genericNode.rawStyle.indexOf('border-start-width:') >= 0) { + lines.push('CSSNodeStyleSetBorder(' + nodeName + ', CSSEdgeStart, ' + + pixelValue(node.style[style]) + ');'); + } else { + lines.push('CSSNodeStyleSetBorder(' + nodeName + ', CSSEdgeLeft, ' + + pixelValue(node.style[style]) + ');'); + } break; case 'border-top-width': lines.push('CSSNodeStyleSetBorder(' + nodeName + ', CSSEdgeTop, ' + pixelValue(node.style[style]) + ');'); break; case 'border-right-width': - lines.push('CSSNodeStyleSetBorder(' + nodeName + ', CSSEdgeRight, ' + - pixelValue(node.style[style]) + ');'); + if (genericNode.rawStyle.indexOf('border-end-width:') >= 0) { + lines.push('CSSNodeStyleSetBorder(' + nodeName + ', CSSEdgeEnd, ' + + pixelValue(node.style[style]) + ');'); + } else { + lines.push('CSSNodeStyleSetBorder(' + nodeName + ', CSSEdgeRight, ' + + pixelValue(node.style[style]) + ');'); + } break; case 'border-bottom-width': lines.push('CSSNodeStyleSetBorder(' + nodeName + ', CSSEdgeBottom, ' + @@ -265,7 +317,13 @@ function setupTestTree(node, nodeName, parentName, index) { for (var i = 0; i < node.children.length; i++) { lines.push(''); var childName = nodeName + '_child' + i; - lines = lines.concat(setupTestTree(node.children[i], childName, nodeName, i)); + lines = lines.concat( + setupTestTree( + node.children[i], + genericNode.children[i], + childName, + nodeName, + i)); } return lines; @@ -367,6 +425,7 @@ function calculateTree(root) { children: calculateTree(child), style: getCSSLayoutStyle(child), declaredStyle: child.style, + rawStyle: child.getAttribute('style'), }); } @@ -409,8 +468,8 @@ function getCSSLayoutStyle(node) { 'height', 'min-height', 'max-height', - ].reduce(function(prev, curr) { - prev[curr] = getComputedStyle(node, null).getPropertyValue(curr); - return prev; + ].reduce(function(map, key) { + map[key] = getComputedStyle(node, null).getPropertyValue(key); + return map; }, {}); } diff --git a/gentest/gentest.sh b/gentest/gentest.sh index cd630367..6c4203e4 100755 --- a/gentest/gentest.sh +++ b/gentest/gentest.sh @@ -1,5 +1,15 @@ rm $(dirname $0)/test.html $EDITOR $(dirname $0)/test.html -export TEST=$(cat test.html) -printf "$(cat $(dirname $0)/test-template.html)" "$(cat $(dirname $0)/test.html)" > $(dirname $0)/test.html + +GENERIC_TEST="$(cat $(dirname $0)/test.html)" +LTR_TEST="$(cat $(dirname $0)/test.html)" +RTL_TEST="$(cat $(dirname $0)/test.html)" + +LTR_TEST=${LTR_TEST//start/left} +LTR_TEST=${LTR_TEST//end/right} + +RTL_TEST=${RTL_TEST//start/right} +RTL_TEST=${RTL_TEST//end/left} + +printf "$(cat $(dirname $0)/test-template.html)" "$LTR_TEST" "$RTL_TEST" "$GENERIC_TEST" > $(dirname $0)/test.html open $(dirname $0)/test.html diff --git a/gentest/test-template.html b/gentest/test-template.html index 779a75d6..81ea2552 100644 --- a/gentest/test-template.html +++ b/gentest/test-template.html @@ -27,18 +27,40 @@ flex-shrink: 0; } - #container > * { + body > * { position: absolute; } + + #ltr-container > * { + position: absolute; + direction: ltr; + } + + #rtl-container > * { + position: absolute; + direction: rtl; + } -
+
%s
+
+ + %s + +
+
+ +
+ + %s + +
diff --git a/tests/CSSLayoutAbsolutePositionTest.cpp b/tests/CSSLayoutAbsolutePositionTest.cpp index d8cd3013..4ac37a9f 100644 --- a/tests/CSSLayoutAbsolutePositionTest.cpp +++ b/tests/CSSLayoutAbsolutePositionTest.cpp @@ -10,24 +10,24 @@ /** * @Generated by gentest/gentest.sh with the following input * -
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
@@ -37,14 +37,14 @@ #include #include -TEST(CSSLayoutTest, absolute_layout_width_height_left_top) { +TEST(CSSLayoutTest, absolute_layout_width_height_start_top) { const CSSNodeRef root = CSSNodeNew(); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); const CSSNodeRef root_child0 = CSSNodeNew(); CSSNodeStyleSetPositionType(root_child0, CSSPositionTypeAbsolute); - CSSNodeStyleSetPosition(root_child0, CSSEdgeLeft, 10); + CSSNodeStyleSetPosition(root_child0, CSSEdgeStart, 10); CSSNodeStyleSetPosition(root_child0, CSSEdgeTop, 10); CSSNodeStyleSetWidth(root_child0, 10); CSSNodeStyleSetHeight(root_child0, 10); @@ -60,16 +60,28 @@ TEST(CSSLayoutTest, absolute_layout_width_height_left_top) { ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(80, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); } -TEST(CSSLayoutTest, absolute_layout_width_height_right_bottom) { +TEST(CSSLayoutTest, absolute_layout_width_height_end_bottom) { const CSSNodeRef root = CSSNodeNew(); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); const CSSNodeRef root_child0 = CSSNodeNew(); CSSNodeStyleSetPositionType(root_child0, CSSPositionTypeAbsolute); - CSSNodeStyleSetPosition(root_child0, CSSEdgeRight, 10); + CSSNodeStyleSetPosition(root_child0, CSSEdgeEnd, 10); CSSNodeStyleSetPosition(root_child0, CSSEdgeBottom, 10); CSSNodeStyleSetWidth(root_child0, 10); CSSNodeStyleSetHeight(root_child0, 10); @@ -85,18 +97,30 @@ TEST(CSSLayoutTest, absolute_layout_width_height_right_bottom) { ASSERT_EQ(80, CSSNodeLayoutGetTop(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(10, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(80, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); } -TEST(CSSLayoutTest, absolute_layout_left_top_right_bottom) { +TEST(CSSLayoutTest, absolute_layout_start_top_end_bottom) { const CSSNodeRef root = CSSNodeNew(); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); const CSSNodeRef root_child0 = CSSNodeNew(); CSSNodeStyleSetPositionType(root_child0, CSSPositionTypeAbsolute); - CSSNodeStyleSetPosition(root_child0, CSSEdgeLeft, 10); + CSSNodeStyleSetPosition(root_child0, CSSEdgeStart, 10); CSSNodeStyleSetPosition(root_child0, CSSEdgeTop, 10); - CSSNodeStyleSetPosition(root_child0, CSSEdgeRight, 10); + CSSNodeStyleSetPosition(root_child0, CSSEdgeEnd, 10); CSSNodeStyleSetPosition(root_child0, CSSEdgeBottom, 10); CSSNodeInsertChild(root, root_child0, 0); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); @@ -110,18 +134,30 @@ TEST(CSSLayoutTest, absolute_layout_left_top_right_bottom) { ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); ASSERT_EQ(80, CSSNodeLayoutGetWidth(root_child0)); ASSERT_EQ(80, CSSNodeLayoutGetHeight(root_child0)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(10, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(80, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(80, CSSNodeLayoutGetHeight(root_child0)); } -TEST(CSSLayoutTest, absolute_layout_width_height_left_top_right_bottom) { +TEST(CSSLayoutTest, absolute_layout_width_height_start_top_end_bottom) { const CSSNodeRef root = CSSNodeNew(); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); const CSSNodeRef root_child0 = CSSNodeNew(); CSSNodeStyleSetPositionType(root_child0, CSSPositionTypeAbsolute); - CSSNodeStyleSetPosition(root_child0, CSSEdgeLeft, 10); + CSSNodeStyleSetPosition(root_child0, CSSEdgeStart, 10); CSSNodeStyleSetPosition(root_child0, CSSEdgeTop, 10); - CSSNodeStyleSetPosition(root_child0, CSSEdgeRight, 10); + CSSNodeStyleSetPosition(root_child0, CSSEdgeEnd, 10); CSSNodeStyleSetPosition(root_child0, CSSEdgeBottom, 10); CSSNodeStyleSetWidth(root_child0, 10); CSSNodeStyleSetHeight(root_child0, 10); @@ -137,6 +173,18 @@ TEST(CSSLayoutTest, absolute_layout_width_height_left_top_right_bottom) { ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(80, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); } TEST(CSSLayoutTest, do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent) { @@ -170,4 +218,21 @@ TEST(CSSLayoutTest, do_not_clamp_height_of_absolute_node_to_height_of_its_overfl ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0_child0)); ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0_child0)); ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0_child0)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(50, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(50, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(-50, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0_child0)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0_child0)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0_child0)); } diff --git a/tests/CSSLayoutAlignContentTest.cpp b/tests/CSSLayoutAlignContentTest.cpp index 57d7bc88..2c0c59ac 100644 --- a/tests/CSSLayoutAlignContentTest.cpp +++ b/tests/CSSLayoutAlignContentTest.cpp @@ -49,7 +49,6 @@ TEST(CSSLayoutTest, align_content_flex_start) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignContent(root, CSSAlignFlexStart); CSSNodeStyleSetFlexWrap(root, CSSWrapTypeWrap); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); @@ -109,11 +108,42 @@ TEST(CSSLayoutTest, align_content_flex_start) { ASSERT_EQ(40, CSSNodeLayoutGetTop(root_child4)); ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child4)); ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child4)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(50, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + + ASSERT_EQ(50, CSSNodeLayoutGetLeft(root_child1)); + ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child1)); + ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); + + ASSERT_EQ(50, CSSNodeLayoutGetLeft(root_child2)); + ASSERT_EQ(20, CSSNodeLayoutGetTop(root_child2)); + ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child2)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); + + ASSERT_EQ(50, CSSNodeLayoutGetLeft(root_child3)); + ASSERT_EQ(30, CSSNodeLayoutGetTop(root_child3)); + ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child3)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child3)); + + ASSERT_EQ(50, CSSNodeLayoutGetLeft(root_child4)); + ASSERT_EQ(40, CSSNodeLayoutGetTop(root_child4)); + ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child4)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child4)); } TEST(CSSLayoutTest, align_content_flex_end) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignContent(root, CSSAlignFlexEnd); CSSNodeStyleSetFlexWrap(root, CSSWrapTypeWrap); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); @@ -173,6 +203,38 @@ TEST(CSSLayoutTest, align_content_flex_end) { ASSERT_EQ(40, CSSNodeLayoutGetTop(root_child4)); ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child4)); ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child4)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(50, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + + ASSERT_EQ(50, CSSNodeLayoutGetLeft(root_child1)); + ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child1)); + ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); + + ASSERT_EQ(50, CSSNodeLayoutGetLeft(root_child2)); + ASSERT_EQ(20, CSSNodeLayoutGetTop(root_child2)); + ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child2)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); + + ASSERT_EQ(50, CSSNodeLayoutGetLeft(root_child3)); + ASSERT_EQ(30, CSSNodeLayoutGetTop(root_child3)); + ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child3)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child3)); + + ASSERT_EQ(50, CSSNodeLayoutGetLeft(root_child4)); + ASSERT_EQ(40, CSSNodeLayoutGetTop(root_child4)); + ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child4)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child4)); } TEST(CSSLayoutTest, align_content_center) { @@ -237,6 +299,38 @@ TEST(CSSLayoutTest, align_content_center) { ASSERT_EQ(40, CSSNodeLayoutGetTop(root_child4)); ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child4)); ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child4)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(50, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + + ASSERT_EQ(50, CSSNodeLayoutGetLeft(root_child1)); + ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child1)); + ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); + + ASSERT_EQ(50, CSSNodeLayoutGetLeft(root_child2)); + ASSERT_EQ(20, CSSNodeLayoutGetTop(root_child2)); + ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child2)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); + + ASSERT_EQ(50, CSSNodeLayoutGetLeft(root_child3)); + ASSERT_EQ(30, CSSNodeLayoutGetTop(root_child3)); + ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child3)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child3)); + + ASSERT_EQ(50, CSSNodeLayoutGetLeft(root_child4)); + ASSERT_EQ(40, CSSNodeLayoutGetTop(root_child4)); + ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child4)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child4)); } TEST(CSSLayoutTest, align_content_stretch) { @@ -296,4 +390,36 @@ TEST(CSSLayoutTest, align_content_stretch) { ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child4)); ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child4)); ASSERT_EQ(0, CSSNodeLayoutGetHeight(root_child4)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(50, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetHeight(root_child0)); + + ASSERT_EQ(50, CSSNodeLayoutGetLeft(root_child1)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); + ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); + ASSERT_EQ(0, CSSNodeLayoutGetHeight(root_child1)); + + ASSERT_EQ(50, CSSNodeLayoutGetLeft(root_child2)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2)); + ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child2)); + ASSERT_EQ(0, CSSNodeLayoutGetHeight(root_child2)); + + ASSERT_EQ(50, CSSNodeLayoutGetLeft(root_child3)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child3)); + ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child3)); + ASSERT_EQ(0, CSSNodeLayoutGetHeight(root_child3)); + + ASSERT_EQ(50, CSSNodeLayoutGetLeft(root_child4)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child4)); + ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child4)); + ASSERT_EQ(0, CSSNodeLayoutGetHeight(root_child4)); } diff --git a/tests/CSSLayoutAlignItemsTest.cpp b/tests/CSSLayoutAlignItemsTest.cpp index f78e6809..0ae1d8ab 100644 --- a/tests/CSSLayoutAlignItemsTest.cpp +++ b/tests/CSSLayoutAlignItemsTest.cpp @@ -50,6 +50,18 @@ TEST(CSSLayoutTest, align_items_stretch) { ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); } TEST(CSSLayoutTest, align_items_center) { @@ -74,16 +86,26 @@ TEST(CSSLayoutTest, align_items_center) { ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(45, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); } TEST(CSSLayoutTest, align_items_flex_start) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetAlignSelf(root_child0, CSSAlignFlexStart); CSSNodeStyleSetWidth(root_child0, 10); CSSNodeStyleSetHeight(root_child0, 10); CSSNodeInsertChild(root, root_child0, 0); @@ -98,20 +120,42 @@ TEST(CSSLayoutTest, align_items_flex_start) { ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); -} -TEST(CSSLayoutTest, align_items_flex_end) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, CSSAlignFlexEnd); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); - - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetAlignSelf(root_child0, CSSAlignFlexEnd); - CSSNodeStyleSetWidth(root_child0, 10); - CSSNodeStyleSetHeight(root_child0, 10); - CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(90, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); +} + +TEST(CSSLayoutTest, align_items_flex_end) { + const CSSNodeRef root = CSSNodeNew(); + CSSNodeStyleSetWidth(root, 100); + CSSNodeStyleSetHeight(root, 100); + + const CSSNodeRef root_child0 = CSSNodeNew(); + CSSNodeStyleSetWidth(root_child0, 10); + CSSNodeStyleSetHeight(root_child0, 10); + CSSNodeInsertChild(root, root_child0, 0); + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); diff --git a/tests/CSSLayoutAlignSelfTest.cpp b/tests/CSSLayoutAlignSelfTest.cpp index e1181b72..170a10c0 100644 --- a/tests/CSSLayoutAlignSelfTest.cpp +++ b/tests/CSSLayoutAlignSelfTest.cpp @@ -52,6 +52,18 @@ TEST(CSSLayoutTest, align_self_center) { ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(45, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); } TEST(CSSLayoutTest, align_self_flex_end) { @@ -60,7 +72,6 @@ TEST(CSSLayoutTest, align_self_flex_end) { CSSNodeStyleSetHeight(root, 100); const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetAlignSelf(root_child0, CSSAlignFlexEnd); CSSNodeStyleSetWidth(root_child0, 10); CSSNodeStyleSetHeight(root_child0, 10); CSSNodeInsertChild(root, root_child0, 0); @@ -71,6 +82,18 @@ TEST(CSSLayoutTest, align_self_flex_end) { ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + ASSERT_EQ(90, CSSNodeLayoutGetLeft(root_child0)); ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); @@ -83,7 +106,6 @@ TEST(CSSLayoutTest, align_self_flex_start) { CSSNodeStyleSetHeight(root, 100); const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetAlignSelf(root_child0, CSSAlignFlexStart); CSSNodeStyleSetWidth(root_child0, 10); CSSNodeStyleSetHeight(root_child0, 10); CSSNodeInsertChild(root, root_child0, 0); @@ -98,20 +120,42 @@ TEST(CSSLayoutTest, align_self_flex_start) { ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); -} -TEST(CSSLayoutTest, align_self_flex_end_override_flex_start) { - const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart); - CSSNodeStyleSetWidth(root, 100); - CSSNodeStyleSetHeight(root, 100); - - const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetAlignSelf(root_child0, CSSAlignFlexEnd); - CSSNodeStyleSetWidth(root_child0, 10); - CSSNodeStyleSetHeight(root_child0, 10); - CSSNodeInsertChild(root, root_child0, 0); - CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(90, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); +} + +TEST(CSSLayoutTest, align_self_flex_end_override_flex_start) { + const CSSNodeRef root = CSSNodeNew(); + CSSNodeStyleSetWidth(root, 100); + CSSNodeStyleSetHeight(root, 100); + + const CSSNodeRef root_child0 = CSSNodeNew(); + CSSNodeStyleSetWidth(root_child0, 10); + CSSNodeStyleSetHeight(root_child0, 10); + CSSNodeInsertChild(root, root_child0, 0); + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); diff --git a/tests/CSSLayoutBorderTest.cpp b/tests/CSSLayoutBorderTest.cpp index d99b9e43..871b01bd 100644 --- a/tests/CSSLayoutBorderTest.cpp +++ b/tests/CSSLayoutBorderTest.cpp @@ -25,7 +25,7 @@
-
+
* @@ -46,6 +46,13 @@ TEST(CSSLayoutTest, border_no_size) { ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_EQ(20, CSSNodeLayoutGetWidth(root)); ASSERT_EQ(20, CSSNodeLayoutGetHeight(root)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(20, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(20, CSSNodeLayoutGetHeight(root)); } TEST(CSSLayoutTest, border_container_match_child) { @@ -70,6 +77,18 @@ TEST(CSSLayoutTest, border_container_match_child) { ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(30, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(30, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(10, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); } TEST(CSSLayoutTest, border_flex_child) { @@ -96,6 +115,18 @@ TEST(CSSLayoutTest, border_flex_child) { ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_EQ(80, CSSNodeLayoutGetHeight(root_child0)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(80, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(80, CSSNodeLayoutGetHeight(root_child0)); } TEST(CSSLayoutTest, border_stretch_child) { @@ -121,14 +152,26 @@ TEST(CSSLayoutTest, border_stretch_child) { ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); ASSERT_EQ(80, CSSNodeLayoutGetWidth(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(10, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(80, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); } TEST(CSSLayoutTest, border_center_child) { const CSSNodeRef root = CSSNodeNew(); CSSNodeStyleSetJustifyContent(root, CSSJustifyCenter); CSSNodeStyleSetAlignItems(root, CSSAlignCenter); - CSSNodeStyleSetBorder(root, CSSEdgeLeft, 10); - CSSNodeStyleSetBorder(root, CSSEdgeRight, 20); + CSSNodeStyleSetBorder(root, CSSEdgeStart, 10); + CSSNodeStyleSetBorder(root, CSSEdgeEnd, 20); CSSNodeStyleSetBorder(root, CSSEdgeBottom, 20); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); @@ -149,4 +192,16 @@ TEST(CSSLayoutTest, border_center_child) { ASSERT_EQ(35, CSSNodeLayoutGetTop(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(50, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(35, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); } diff --git a/tests/CSSLayoutFlexDirectionTest.cpp b/tests/CSSLayoutFlexDirectionTest.cpp index 7699208c..9f23ae1b 100644 --- a/tests/CSSLayoutFlexDirectionTest.cpp +++ b/tests/CSSLayoutFlexDirectionTest.cpp @@ -87,6 +87,28 @@ TEST(CSSLayoutTest, flex_direction_column_no_height) { ASSERT_EQ(20, CSSNodeLayoutGetTop(root_child2)); ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(30, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); + ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child1)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); + ASSERT_EQ(20, CSSNodeLayoutGetTop(root_child2)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); } TEST(CSSLayoutTest, flex_direction_row_no_width) { @@ -126,6 +148,28 @@ TEST(CSSLayoutTest, flex_direction_row_no_width) { ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2)); ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child2)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(30, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(20, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + + ASSERT_EQ(10, CSSNodeLayoutGetLeft(root_child1)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); + ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child1)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2)); + ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child2)); } TEST(CSSLayoutTest, flex_direction_column) { @@ -165,6 +209,28 @@ TEST(CSSLayoutTest, flex_direction_column) { ASSERT_EQ(20, CSSNodeLayoutGetTop(root_child2)); ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); + ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child1)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); + ASSERT_EQ(20, CSSNodeLayoutGetTop(root_child2)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); } TEST(CSSLayoutTest, flex_direction_row) { @@ -205,6 +271,28 @@ TEST(CSSLayoutTest, flex_direction_row) { ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2)); ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child2)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(90, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + + ASSERT_EQ(80, CSSNodeLayoutGetLeft(root_child1)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); + ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child1)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); + + ASSERT_EQ(70, CSSNodeLayoutGetLeft(root_child2)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2)); + ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child2)); } TEST(CSSLayoutTest, flex_direction_column_reverse) { @@ -245,6 +333,28 @@ TEST(CSSLayoutTest, flex_direction_column_reverse) { ASSERT_EQ(70, CSSNodeLayoutGetTop(root_child2)); ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(90, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); + ASSERT_EQ(80, CSSNodeLayoutGetTop(root_child1)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); + ASSERT_EQ(70, CSSNodeLayoutGetTop(root_child2)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); } TEST(CSSLayoutTest, flex_direction_row_reverse) { @@ -285,4 +395,26 @@ TEST(CSSLayoutTest, flex_direction_row_reverse) { ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2)); ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child2)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + + ASSERT_EQ(10, CSSNodeLayoutGetLeft(root_child1)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); + ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child1)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); + + ASSERT_EQ(20, CSSNodeLayoutGetLeft(root_child2)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2)); + ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child2)); } diff --git a/tests/CSSLayoutFlexTest.cpp b/tests/CSSLayoutFlexTest.cpp index 2c8caeb5..488de4b9 100644 --- a/tests/CSSLayoutFlexTest.cpp +++ b/tests/CSSLayoutFlexTest.cpp @@ -29,11 +29,6 @@
- -
-
-
-
* */ @@ -69,6 +64,23 @@ TEST(CSSLayoutTest, flex_basis_flex_grow_column) { ASSERT_EQ(75, CSSNodeLayoutGetTop(root_child1)); ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); ASSERT_EQ(25, CSSNodeLayoutGetHeight(root_child1)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(75, CSSNodeLayoutGetHeight(root_child0)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); + ASSERT_EQ(75, CSSNodeLayoutGetTop(root_child1)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); + ASSERT_EQ(25, CSSNodeLayoutGetHeight(root_child1)); } TEST(CSSLayoutTest, flex_basis_flex_grow_row) { @@ -101,6 +113,23 @@ TEST(CSSLayoutTest, flex_basis_flex_grow_row) { ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); ASSERT_EQ(25, CSSNodeLayoutGetWidth(root_child1)); ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(25, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(75, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); + ASSERT_EQ(25, CSSNodeLayoutGetWidth(root_child1)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); } TEST(CSSLayoutTest, flex_basis_flex_shrink_column) { @@ -132,6 +161,23 @@ TEST(CSSLayoutTest, flex_basis_flex_shrink_column) { ASSERT_EQ(50, CSSNodeLayoutGetTop(root_child1)); ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child1)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); + ASSERT_EQ(50, CSSNodeLayoutGetTop(root_child1)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); + ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child1)); } TEST(CSSLayoutTest, flex_basis_flex_shrink_row) { @@ -164,4 +210,21 @@ TEST(CSSLayoutTest, flex_basis_flex_shrink_row) { ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(50, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); + ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); } diff --git a/tests/CSSLayoutFlexWrapTest.cpp b/tests/CSSLayoutFlexWrapTest.cpp index f2240c3b..5a9c3869 100644 --- a/tests/CSSLayoutFlexWrapTest.cpp +++ b/tests/CSSLayoutFlexWrapTest.cpp @@ -40,25 +40,21 @@ TEST(CSSLayoutTest, wrap_column) { CSSNodeStyleSetHeight(root, 100); const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetAlignSelf(root_child0, CSSAlignStretch); CSSNodeStyleSetWidth(root_child0, 30); CSSNodeStyleSetHeight(root_child0, 30); CSSNodeInsertChild(root, root_child0, 0); const CSSNodeRef root_child1 = CSSNodeNew(); - CSSNodeStyleSetAlignSelf(root_child1, CSSAlignStretch); CSSNodeStyleSetWidth(root_child1, 30); CSSNodeStyleSetHeight(root_child1, 30); CSSNodeInsertChild(root, root_child1, 1); const CSSNodeRef root_child2 = CSSNodeNew(); - CSSNodeStyleSetAlignSelf(root_child2, CSSAlignStretch); CSSNodeStyleSetWidth(root_child2, 30); CSSNodeStyleSetHeight(root_child2, 30); CSSNodeInsertChild(root, root_child2, 2); const CSSNodeRef root_child3 = CSSNodeNew(); - CSSNodeStyleSetAlignSelf(root_child3, CSSAlignStretch); CSSNodeStyleSetWidth(root_child3, 30); CSSNodeStyleSetHeight(root_child3, 30); CSSNodeInsertChild(root, root_child3, 3); @@ -88,6 +84,33 @@ TEST(CSSLayoutTest, wrap_column) { ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child3)); ASSERT_EQ(30, CSSNodeLayoutGetWidth(root_child3)); ASSERT_EQ(30, CSSNodeLayoutGetHeight(root_child3)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(60, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(30, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(30, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(30, CSSNodeLayoutGetHeight(root_child0)); + + ASSERT_EQ(30, CSSNodeLayoutGetLeft(root_child1)); + ASSERT_EQ(30, CSSNodeLayoutGetTop(root_child1)); + ASSERT_EQ(30, CSSNodeLayoutGetWidth(root_child1)); + ASSERT_EQ(30, CSSNodeLayoutGetHeight(root_child1)); + + ASSERT_EQ(30, CSSNodeLayoutGetLeft(root_child2)); + ASSERT_EQ(60, CSSNodeLayoutGetTop(root_child2)); + ASSERT_EQ(30, CSSNodeLayoutGetWidth(root_child2)); + ASSERT_EQ(30, CSSNodeLayoutGetHeight(root_child2)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child3)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child3)); + ASSERT_EQ(30, CSSNodeLayoutGetWidth(root_child3)); + ASSERT_EQ(30, CSSNodeLayoutGetHeight(root_child3)); } TEST(CSSLayoutTest, wrap_row) { @@ -97,25 +120,21 @@ TEST(CSSLayoutTest, wrap_row) { CSSNodeStyleSetWidth(root, 100); const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetAlignSelf(root_child0, CSSAlignStretch); CSSNodeStyleSetWidth(root_child0, 30); CSSNodeStyleSetHeight(root_child0, 30); CSSNodeInsertChild(root, root_child0, 0); const CSSNodeRef root_child1 = CSSNodeNew(); - CSSNodeStyleSetAlignSelf(root_child1, CSSAlignStretch); CSSNodeStyleSetWidth(root_child1, 30); CSSNodeStyleSetHeight(root_child1, 30); CSSNodeInsertChild(root, root_child1, 1); const CSSNodeRef root_child2 = CSSNodeNew(); - CSSNodeStyleSetAlignSelf(root_child2, CSSAlignStretch); CSSNodeStyleSetWidth(root_child2, 30); CSSNodeStyleSetHeight(root_child2, 30); CSSNodeInsertChild(root, root_child2, 2); const CSSNodeRef root_child3 = CSSNodeNew(); - CSSNodeStyleSetAlignSelf(root_child3, CSSAlignStretch); CSSNodeStyleSetWidth(root_child3, 30); CSSNodeStyleSetHeight(root_child3, 30); CSSNodeInsertChild(root, root_child3, 3); @@ -145,4 +164,31 @@ TEST(CSSLayoutTest, wrap_row) { ASSERT_EQ(30, CSSNodeLayoutGetTop(root_child3)); ASSERT_EQ(30, CSSNodeLayoutGetWidth(root_child3)); ASSERT_EQ(30, CSSNodeLayoutGetHeight(root_child3)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(60, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(70, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(30, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(30, CSSNodeLayoutGetHeight(root_child0)); + + ASSERT_EQ(40, CSSNodeLayoutGetLeft(root_child1)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); + ASSERT_EQ(30, CSSNodeLayoutGetWidth(root_child1)); + ASSERT_EQ(30, CSSNodeLayoutGetHeight(root_child1)); + + ASSERT_EQ(10, CSSNodeLayoutGetLeft(root_child2)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2)); + ASSERT_EQ(30, CSSNodeLayoutGetWidth(root_child2)); + ASSERT_EQ(30, CSSNodeLayoutGetHeight(root_child2)); + + ASSERT_EQ(70, CSSNodeLayoutGetLeft(root_child3)); + ASSERT_EQ(30, CSSNodeLayoutGetTop(root_child3)); + ASSERT_EQ(30, CSSNodeLayoutGetWidth(root_child3)); + ASSERT_EQ(30, CSSNodeLayoutGetHeight(root_child3)); } diff --git a/tests/CSSLayoutJustifyContentTest.cpp b/tests/CSSLayoutJustifyContentTest.cpp index 595ff627..a804dcf3 100644 --- a/tests/CSSLayoutJustifyContentTest.cpp +++ b/tests/CSSLayoutJustifyContentTest.cpp @@ -113,12 +113,33 @@ TEST(CSSLayoutTest, justify_content_row_flex_start) { ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2)); ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); ASSERT_EQ(102, CSSNodeLayoutGetHeight(root_child2)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(102, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(102, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(92, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(102, CSSNodeLayoutGetHeight(root_child0)); + + ASSERT_EQ(82, CSSNodeLayoutGetLeft(root_child1)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); + ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child1)); + ASSERT_EQ(102, CSSNodeLayoutGetHeight(root_child1)); + + ASSERT_EQ(72, CSSNodeLayoutGetLeft(root_child2)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2)); + ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); + ASSERT_EQ(102, CSSNodeLayoutGetHeight(root_child2)); } TEST(CSSLayoutTest, justify_content_row_flex_end) { const CSSNodeRef root = CSSNodeNew(); CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionRow); - CSSNodeStyleSetJustifyContent(root, CSSJustifyFlexEnd); CSSNodeStyleSetWidth(root, 102); CSSNodeStyleSetHeight(root, 102); @@ -140,7 +161,29 @@ TEST(CSSLayoutTest, justify_content_row_flex_end) { ASSERT_EQ(102, CSSNodeLayoutGetWidth(root)); ASSERT_EQ(102, CSSNodeLayoutGetHeight(root)); - ASSERT_EQ(72, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(102, CSSNodeLayoutGetHeight(root_child0)); + + ASSERT_EQ(10, CSSNodeLayoutGetLeft(root_child1)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); + ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child1)); + ASSERT_EQ(102, CSSNodeLayoutGetHeight(root_child1)); + + ASSERT_EQ(20, CSSNodeLayoutGetLeft(root_child2)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2)); + ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); + ASSERT_EQ(102, CSSNodeLayoutGetHeight(root_child2)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(102, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(102, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(92, CSSNodeLayoutGetLeft(root_child0)); ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_EQ(102, CSSNodeLayoutGetHeight(root_child0)); @@ -150,7 +193,7 @@ TEST(CSSLayoutTest, justify_content_row_flex_end) { ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child1)); ASSERT_EQ(102, CSSNodeLayoutGetHeight(root_child1)); - ASSERT_EQ(92, CSSNodeLayoutGetLeft(root_child2)); + ASSERT_EQ(72, CSSNodeLayoutGetLeft(root_child2)); ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2)); ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); ASSERT_EQ(102, CSSNodeLayoutGetHeight(root_child2)); @@ -195,6 +238,28 @@ TEST(CSSLayoutTest, justify_content_row_center) { ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2)); ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); ASSERT_EQ(102, CSSNodeLayoutGetHeight(root_child2)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(102, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(102, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(56, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(102, CSSNodeLayoutGetHeight(root_child0)); + + ASSERT_EQ(46, CSSNodeLayoutGetLeft(root_child1)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); + ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child1)); + ASSERT_EQ(102, CSSNodeLayoutGetHeight(root_child1)); + + ASSERT_EQ(36, CSSNodeLayoutGetLeft(root_child2)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2)); + ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); + ASSERT_EQ(102, CSSNodeLayoutGetHeight(root_child2)); } TEST(CSSLayoutTest, justify_content_row_space_between) { @@ -236,6 +301,28 @@ TEST(CSSLayoutTest, justify_content_row_space_between) { ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2)); ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); ASSERT_EQ(102, CSSNodeLayoutGetHeight(root_child2)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(102, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(102, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(92, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(102, CSSNodeLayoutGetHeight(root_child0)); + + ASSERT_EQ(46, CSSNodeLayoutGetLeft(root_child1)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); + ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child1)); + ASSERT_EQ(102, CSSNodeLayoutGetHeight(root_child1)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2)); + ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); + ASSERT_EQ(102, CSSNodeLayoutGetHeight(root_child2)); } TEST(CSSLayoutTest, justify_content_row_space_around) { @@ -277,6 +364,28 @@ TEST(CSSLayoutTest, justify_content_row_space_around) { ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2)); ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); ASSERT_EQ(102, CSSNodeLayoutGetHeight(root_child2)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(102, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(102, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(80, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(102, CSSNodeLayoutGetHeight(root_child0)); + + ASSERT_EQ(46, CSSNodeLayoutGetLeft(root_child1)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); + ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child1)); + ASSERT_EQ(102, CSSNodeLayoutGetHeight(root_child1)); + + ASSERT_EQ(12, CSSNodeLayoutGetLeft(root_child2)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2)); + ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); + ASSERT_EQ(102, CSSNodeLayoutGetHeight(root_child2)); } TEST(CSSLayoutTest, justify_content_column_flex_start) { @@ -315,11 +424,32 @@ TEST(CSSLayoutTest, justify_content_column_flex_start) { ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child2)); ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child2)); ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(102, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(102, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); + ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child1)); + ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child1)); + ASSERT_EQ(0, CSSNodeLayoutGetHeight(root_child1)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); + ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child2)); + ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child2)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); } TEST(CSSLayoutTest, justify_content_column_flex_end) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetJustifyContent(root, CSSJustifyFlexEnd); CSSNodeStyleSetWidth(root, 102); CSSNodeStyleSetHeight(root, 102); @@ -342,17 +472,39 @@ TEST(CSSLayoutTest, justify_content_column_flex_end) { ASSERT_EQ(102, CSSNodeLayoutGetHeight(root)); ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(72, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); - ASSERT_EQ(82, CSSNodeLayoutGetTop(root_child1)); + ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child1)); ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child1)); ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); - ASSERT_EQ(92, CSSNodeLayoutGetTop(root_child2)); + ASSERT_EQ(20, CSSNodeLayoutGetTop(root_child2)); + ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child2)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(102, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(102, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); + ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child1)); + ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child1)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); + ASSERT_EQ(20, CSSNodeLayoutGetTop(root_child2)); ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child2)); ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); } @@ -395,6 +547,28 @@ TEST(CSSLayoutTest, justify_content_column_center) { ASSERT_EQ(56, CSSNodeLayoutGetTop(root_child2)); ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child2)); ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(102, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(102, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(36, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); + ASSERT_EQ(46, CSSNodeLayoutGetTop(root_child1)); + ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child1)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); + ASSERT_EQ(56, CSSNodeLayoutGetTop(root_child2)); + ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child2)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); } TEST(CSSLayoutTest, justify_content_column_space_between) { @@ -435,6 +609,28 @@ TEST(CSSLayoutTest, justify_content_column_space_between) { ASSERT_EQ(92, CSSNodeLayoutGetTop(root_child2)); ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child2)); ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(102, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(102, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); + ASSERT_EQ(46, CSSNodeLayoutGetTop(root_child1)); + ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child1)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); + ASSERT_EQ(92, CSSNodeLayoutGetTop(root_child2)); + ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child2)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); } TEST(CSSLayoutTest, justify_content_column_space_around) { @@ -475,4 +671,26 @@ TEST(CSSLayoutTest, justify_content_column_space_around) { ASSERT_EQ(80, CSSNodeLayoutGetTop(root_child2)); ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child2)); ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(102, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(102, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(12, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); + ASSERT_EQ(46, CSSNodeLayoutGetTop(root_child1)); + ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child1)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); + ASSERT_EQ(80, CSSNodeLayoutGetTop(root_child2)); + ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child2)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); } diff --git a/tests/CSSLayoutMarginTest.cpp b/tests/CSSLayoutMarginTest.cpp index a2f10acd..008a3ce7 100644 --- a/tests/CSSLayoutMarginTest.cpp +++ b/tests/CSSLayoutMarginTest.cpp @@ -10,16 +10,16 @@ /** * @Generated by gentest/gentest.sh with the following input * -
-
+
+
-
-
+
+
@@ -27,7 +27,7 @@
-
+
@@ -39,11 +39,11 @@
-
+
-
+
@@ -57,14 +57,14 @@ #include #include -TEST(CSSLayoutTest, margin_left) { +TEST(CSSLayoutTest, margin_start) { const CSSNodeRef root = CSSNodeNew(); CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionRow); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetMargin(root_child0, CSSEdgeLeft, 10); + CSSNodeStyleSetMargin(root_child0, CSSEdgeStart, 10); CSSNodeStyleSetWidth(root_child0, 10); CSSNodeInsertChild(root, root_child0, 0); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); @@ -78,6 +78,18 @@ TEST(CSSLayoutTest, margin_left) { ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(80, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); } TEST(CSSLayoutTest, margin_top) { @@ -100,17 +112,28 @@ TEST(CSSLayoutTest, margin_top) { ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); } -TEST(CSSLayoutTest, margin_right) { +TEST(CSSLayoutTest, margin_end) { const CSSNodeRef root = CSSNodeNew(); CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionRow); - CSSNodeStyleSetJustifyContent(root, CSSJustifyFlexEnd); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); const CSSNodeRef root_child0 = CSSNodeNew(); - CSSNodeStyleSetMargin(root_child0, CSSEdgeRight, 10); + CSSNodeStyleSetMargin(root_child0, CSSEdgeEnd, 10); CSSNodeStyleSetWidth(root_child0, 10); CSSNodeInsertChild(root, root_child0, 0); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); @@ -120,7 +143,19 @@ TEST(CSSLayoutTest, margin_right) { ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); - ASSERT_EQ(80, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(90, CSSNodeLayoutGetLeft(root_child0)); ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); @@ -128,7 +163,6 @@ TEST(CSSLayoutTest, margin_right) { TEST(CSSLayoutTest, margin_bottom) { const CSSNodeRef root = CSSNodeNew(); - CSSNodeStyleSetJustifyContent(root, CSSJustifyFlexEnd); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); @@ -144,7 +178,19 @@ TEST(CSSLayoutTest, margin_bottom) { ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); - ASSERT_EQ(80, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); } @@ -157,7 +203,7 @@ TEST(CSSLayoutTest, margin_and_flex_row) { const CSSNodeRef root_child0 = CSSNodeNew(); CSSNodeStyleSetFlexGrow(root_child0, 1); - CSSNodeStyleSetMargin(root_child0, CSSEdgeLeft, 10); + CSSNodeStyleSetMargin(root_child0, CSSEdgeStart, 10); CSSNodeInsertChild(root, root_child0, 0); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); @@ -170,6 +216,18 @@ TEST(CSSLayoutTest, margin_and_flex_row) { ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_EQ(90, CSSNodeLayoutGetWidth(root_child0)); ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(90, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); } TEST(CSSLayoutTest, margin_and_flex_column) { @@ -192,6 +250,18 @@ TEST(CSSLayoutTest, margin_and_flex_column) { ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); ASSERT_EQ(90, CSSNodeLayoutGetHeight(root_child0)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(90, CSSNodeLayoutGetHeight(root_child0)); } TEST(CSSLayoutTest, margin_and_stretch_row) { @@ -215,6 +285,18 @@ TEST(CSSLayoutTest, margin_and_stretch_row) { ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); ASSERT_EQ(90, CSSNodeLayoutGetHeight(root_child0)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(90, CSSNodeLayoutGetHeight(root_child0)); } TEST(CSSLayoutTest, margin_and_stretch_column) { @@ -224,7 +306,7 @@ TEST(CSSLayoutTest, margin_and_stretch_column) { const CSSNodeRef root_child0 = CSSNodeNew(); CSSNodeStyleSetFlexGrow(root_child0, 1); - CSSNodeStyleSetMargin(root_child0, CSSEdgeLeft, 10); + CSSNodeStyleSetMargin(root_child0, CSSEdgeStart, 10); CSSNodeInsertChild(root, root_child0, 0); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); @@ -237,6 +319,18 @@ TEST(CSSLayoutTest, margin_and_stretch_column) { ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_EQ(90, CSSNodeLayoutGetWidth(root_child0)); ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(90, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); } TEST(CSSLayoutTest, margin_with_sibling_row) { @@ -268,6 +362,23 @@ TEST(CSSLayoutTest, margin_with_sibling_row) { ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(50, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); + ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); } TEST(CSSLayoutTest, margin_with_sibling_column) { @@ -298,4 +409,21 @@ TEST(CSSLayoutTest, margin_with_sibling_column) { ASSERT_EQ(50, CSSNodeLayoutGetTop(root_child1)); ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child1)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); + ASSERT_EQ(50, CSSNodeLayoutGetTop(root_child1)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); + ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child1)); } diff --git a/tests/CSSLayoutMinMaxDimensionTest.cpp b/tests/CSSLayoutMinMaxDimensionTest.cpp index d50ee450..b81df8f8 100644 --- a/tests/CSSLayoutMinMaxDimensionTest.cpp +++ b/tests/CSSLayoutMinMaxDimensionTest.cpp @@ -53,6 +53,18 @@ TEST(CSSLayoutTest, max_width) { ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(50, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); } TEST(CSSLayoutTest, max_height) { @@ -76,6 +88,18 @@ TEST(CSSLayoutTest, max_height) { ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(90, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0)); } TEST(CSSLayoutTest, min_height) { @@ -107,6 +131,23 @@ TEST(CSSLayoutTest, min_height) { ASSERT_EQ(80, CSSNodeLayoutGetTop(root_child1)); ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); ASSERT_EQ(20, CSSNodeLayoutGetHeight(root_child1)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(80, CSSNodeLayoutGetHeight(root_child0)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); + ASSERT_EQ(80, CSSNodeLayoutGetTop(root_child1)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); + ASSERT_EQ(20, CSSNodeLayoutGetHeight(root_child1)); } TEST(CSSLayoutTest, min_width) { @@ -139,4 +180,21 @@ TEST(CSSLayoutTest, min_width) { ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); ASSERT_EQ(20, CSSNodeLayoutGetWidth(root_child1)); ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(20, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(80, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); + ASSERT_EQ(20, CSSNodeLayoutGetWidth(root_child1)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); } diff --git a/tests/CSSLayoutPaddingTest.cpp b/tests/CSSLayoutPaddingTest.cpp index 18b23730..55faa669 100644 --- a/tests/CSSLayoutPaddingTest.cpp +++ b/tests/CSSLayoutPaddingTest.cpp @@ -25,7 +25,7 @@
-
+
* @@ -46,6 +46,13 @@ TEST(CSSLayoutTest, padding_no_size) { ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_EQ(20, CSSNodeLayoutGetWidth(root)); ASSERT_EQ(20, CSSNodeLayoutGetHeight(root)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(20, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(20, CSSNodeLayoutGetHeight(root)); } TEST(CSSLayoutTest, padding_container_match_child) { @@ -70,6 +77,18 @@ TEST(CSSLayoutTest, padding_container_match_child) { ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(30, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(30, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(10, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); } TEST(CSSLayoutTest, padding_flex_child) { @@ -96,6 +115,18 @@ TEST(CSSLayoutTest, padding_flex_child) { ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_EQ(80, CSSNodeLayoutGetHeight(root_child0)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(80, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(80, CSSNodeLayoutGetHeight(root_child0)); } TEST(CSSLayoutTest, padding_stretch_child) { @@ -121,14 +152,26 @@ TEST(CSSLayoutTest, padding_stretch_child) { ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); ASSERT_EQ(80, CSSNodeLayoutGetWidth(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(10, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(80, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); } TEST(CSSLayoutTest, padding_center_child) { const CSSNodeRef root = CSSNodeNew(); CSSNodeStyleSetJustifyContent(root, CSSJustifyCenter); CSSNodeStyleSetAlignItems(root, CSSAlignCenter); - CSSNodeStyleSetPadding(root, CSSEdgeLeft, 10); - CSSNodeStyleSetPadding(root, CSSEdgeRight, 20); + CSSNodeStyleSetPadding(root, CSSEdgeStart, 10); + CSSNodeStyleSetPadding(root, CSSEdgeEnd, 20); CSSNodeStyleSetPadding(root, CSSEdgeBottom, 20); CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetHeight(root, 100); @@ -149,4 +192,16 @@ TEST(CSSLayoutTest, padding_center_child) { ASSERT_EQ(35, CSSNodeLayoutGetTop(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); + + CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); + + ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); + ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); + ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); + ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); + + ASSERT_EQ(50, CSSNodeLayoutGetLeft(root_child0)); + ASSERT_EQ(35, CSSNodeLayoutGetTop(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); + ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); }