Generate RTL version of tests

Summary: Generate RTL versions of css-layout tests

Reviewed By: lucasr

Differential Revision: D3863081

fbshipit-source-id: df4debb3c1e371425d7c297f8d013b8042ad1e0e
This commit is contained in:
Emil Sjolander
2016-09-14 08:51:07 -07:00
committed by Facebook Github Bot 0
parent 8fcb265830
commit 21a05417cd
15 changed files with 1251 additions and 126 deletions

View File

@@ -8,10 +8,10 @@
*/ */
window.onload = function() { 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 = [ var lines = [
'/**', '/**',
' * Copyright (c) 2014-present, Facebook, Inc.', ' * Copyright (c) 2014-present, Facebook, Inc.',
@@ -29,7 +29,7 @@ function printTest(rootNode, layoutTree) {
lines.push(' *'); lines.push(' *');
var indentation = 0; var indentation = 0;
lines.push(rootNode.innerHTML.split('\n').map(function(line) { lines.push(genericContainer.innerHTML.split('\n').map(function(line) {
return line.trim(); return line.trim();
}).filter(function(line) { }).filter(function(line) {
return line.length > 0 && line !== '<div id="default"></div>'; return line.length > 0 && line !== '<div id="default"></div>';
@@ -62,17 +62,29 @@ function printTest(rootNode, layoutTree) {
return curr + '\n' + prev; return curr + '\n' + prev;
})); }));
for (var i = 0; i < layoutTree.length - 1; i++) { var LTRLayoutTree = calculateTree(LTRContainer);
lines.push('TEST(CSSLayoutTest, ' + layoutTree[i].name + ') {'); 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; return curr + '\n ' + prev;
})); }));
lines.push(' CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);'); lines.push(' CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);');
lines.push(''); 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; return curr + '\n ' + prev;
})); }));
@@ -100,7 +112,7 @@ function assertTestTree(node, nodeName, parentName) {
return lines; return lines;
} }
function setupTestTree(node, nodeName, parentName, index) { function setupTestTree(node, genericNode, nodeName, parentName, index) {
var lines = [ var lines = [
'const CSSNodeRef ' + nodeName + ' = CSSNodeNew();', 'const CSSNodeRef ' + nodeName + ' = CSSNodeNew();',
]; ];
@@ -167,64 +179,104 @@ function setupTestTree(node, nodeName, parentName, index) {
pixelValue(node.style[style]) + ');'); pixelValue(node.style[style]) + ');');
break; break;
case 'left': case 'left':
lines.push('CSSNodeStyleSetPosition(' + nodeName + ', CSSEdgeLeft, ' + if (genericNode.rawStyle.indexOf('start:') >= 0) {
pixelValue(node.style[style]) + ');'); lines.push('CSSNodeStyleSetPosition(' + nodeName + ', CSSEdgeStart, ' +
pixelValue(node.style[style]) + ');');
} else {
lines.push('CSSNodeStyleSetPosition(' + nodeName + ', CSSEdgeLeft, ' +
pixelValue(node.style[style]) + ');');
}
break; break;
case 'top': case 'top':
lines.push('CSSNodeStyleSetPosition(' + nodeName + ', CSSEdgeTop, ' + lines.push('CSSNodeStyleSetPosition(' + nodeName + ', CSSEdgeTop, ' +
pixelValue(node.style[style]) + ');'); pixelValue(node.style[style]) + ');');
break; break;
case 'right': case 'right':
lines.push('CSSNodeStyleSetPosition(' + nodeName + ', CSSEdgeRight, ' + if (genericNode.rawStyle.indexOf('end:') >= 0) {
pixelValue(node.style[style]) + ');'); lines.push('CSSNodeStyleSetPosition(' + nodeName + ', CSSEdgeEnd, ' +
pixelValue(node.style[style]) + ');');
} else {
lines.push('CSSNodeStyleSetPosition(' + nodeName + ', CSSEdgeRight, ' +
pixelValue(node.style[style]) + ');');
}
break; break;
case 'bottom': case 'bottom':
lines.push('CSSNodeStyleSetPosition(' + nodeName + ', CSSEdgeBottom, ' + lines.push('CSSNodeStyleSetPosition(' + nodeName + ', CSSEdgeBottom, ' +
pixelValue(node.style[style]) + ');'); pixelValue(node.style[style]) + ');');
break; break;
case 'margin-left': case 'margin-left':
lines.push('CSSNodeStyleSetMargin(' + nodeName + ', CSSEdgeLeft, ' + if (genericNode.rawStyle.indexOf('margin-start:') >= 0) {
pixelValue(node.style[style]) + ');'); lines.push('CSSNodeStyleSetMargin(' + nodeName + ', CSSEdgeStart, ' +
pixelValue(node.style[style]) + ');');
} else {
lines.push('CSSNodeStyleSetMargin(' + nodeName + ', CSSEdgeLeft, ' +
pixelValue(node.style[style]) + ');');
}
break; break;
case 'margin-top': case 'margin-top':
lines.push('CSSNodeStyleSetMargin(' + nodeName + ', CSSEdgeTop, ' + lines.push('CSSNodeStyleSetMargin(' + nodeName + ', CSSEdgeTop, ' +
pixelValue(node.style[style]) + ');'); pixelValue(node.style[style]) + ');');
break; break;
case 'margin-right': case 'margin-right':
lines.push('CSSNodeStyleSetMargin(' + nodeName + ', CSSEdgeRight, ' + if (genericNode.rawStyle.indexOf('margin-end:') >= 0) {
pixelValue(node.style[style]) + ');'); lines.push('CSSNodeStyleSetMargin(' + nodeName + ', CSSEdgeEnd, ' +
pixelValue(node.style[style]) + ');');
} else {
lines.push('CSSNodeStyleSetMargin(' + nodeName + ', CSSEdgeRight, ' +
pixelValue(node.style[style]) + ');');
}
break; break;
case 'margin-bottom': case 'margin-bottom':
lines.push('CSSNodeStyleSetMargin(' + nodeName + ', CSSEdgeBottom, ' + lines.push('CSSNodeStyleSetMargin(' + nodeName + ', CSSEdgeBottom, ' +
pixelValue(node.style[style]) + ');'); pixelValue(node.style[style]) + ');');
break; break;
case 'padding-left': case 'padding-left':
lines.push('CSSNodeStyleSetPadding(' + nodeName + ', CSSEdgeLeft, ' + if (genericNode.rawStyle.indexOf('padding-start:') >= 0) {
pixelValue(node.style[style]) + ');'); lines.push('CSSNodeStyleSetPadding(' + nodeName + ', CSSEdgeStart, ' +
pixelValue(node.style[style]) + ');');
} else {
lines.push('CSSNodeStyleSetPadding(' + nodeName + ', CSSEdgeLeft, ' +
pixelValue(node.style[style]) + ');');
}
break; break;
case 'padding-top': case 'padding-top':
lines.push('CSSNodeStyleSetPadding(' + nodeName + ', CSSEdgeTop, ' + lines.push('CSSNodeStyleSetPadding(' + nodeName + ', CSSEdgeTop, ' +
pixelValue(node.style[style]) + ');'); pixelValue(node.style[style]) + ');');
break; break;
case 'padding-right': case 'padding-right':
lines.push('CSSNodeStyleSetPadding(' + nodeName + ', CSSEdgeRight, ' + if (genericNode.rawStyle.indexOf('padding-end:') >= 0) {
pixelValue(node.style[style]) + ');'); lines.push('CSSNodeStyleSetPadding(' + nodeName + ', CSSEdgeEnd, ' +
pixelValue(node.style[style]) + ');');
} else {
lines.push('CSSNodeStyleSetPadding(' + nodeName + ', CSSEdgeRight, ' +
pixelValue(node.style[style]) + ');');
}
break; break;
case 'padding-bottom': case 'padding-bottom':
lines.push('CSSNodeStyleSetPadding(' + nodeName + ', CSSEdgeBottom, ' + lines.push('CSSNodeStyleSetPadding(' + nodeName + ', CSSEdgeBottom, ' +
pixelValue(node.style[style]) + ');'); pixelValue(node.style[style]) + ');');
break; break;
case 'border-left-width': case 'border-left-width':
lines.push('CSSNodeStyleSetBorder(' + nodeName + ', CSSEdgeLeft, ' + if (genericNode.rawStyle.indexOf('border-start-width:') >= 0) {
pixelValue(node.style[style]) + ');'); lines.push('CSSNodeStyleSetBorder(' + nodeName + ', CSSEdgeStart, ' +
pixelValue(node.style[style]) + ');');
} else {
lines.push('CSSNodeStyleSetBorder(' + nodeName + ', CSSEdgeLeft, ' +
pixelValue(node.style[style]) + ');');
}
break; break;
case 'border-top-width': case 'border-top-width':
lines.push('CSSNodeStyleSetBorder(' + nodeName + ', CSSEdgeTop, ' + lines.push('CSSNodeStyleSetBorder(' + nodeName + ', CSSEdgeTop, ' +
pixelValue(node.style[style]) + ');'); pixelValue(node.style[style]) + ');');
break; break;
case 'border-right-width': case 'border-right-width':
lines.push('CSSNodeStyleSetBorder(' + nodeName + ', CSSEdgeRight, ' + if (genericNode.rawStyle.indexOf('border-end-width:') >= 0) {
pixelValue(node.style[style]) + ');'); lines.push('CSSNodeStyleSetBorder(' + nodeName + ', CSSEdgeEnd, ' +
pixelValue(node.style[style]) + ');');
} else {
lines.push('CSSNodeStyleSetBorder(' + nodeName + ', CSSEdgeRight, ' +
pixelValue(node.style[style]) + ');');
}
break; break;
case 'border-bottom-width': case 'border-bottom-width':
lines.push('CSSNodeStyleSetBorder(' + nodeName + ', CSSEdgeBottom, ' + lines.push('CSSNodeStyleSetBorder(' + nodeName + ', CSSEdgeBottom, ' +
@@ -265,7 +317,13 @@ function setupTestTree(node, nodeName, parentName, index) {
for (var i = 0; i < node.children.length; i++) { for (var i = 0; i < node.children.length; i++) {
lines.push(''); lines.push('');
var childName = nodeName + '_child' + i; 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; return lines;
@@ -367,6 +425,7 @@ function calculateTree(root) {
children: calculateTree(child), children: calculateTree(child),
style: getCSSLayoutStyle(child), style: getCSSLayoutStyle(child),
declaredStyle: child.style, declaredStyle: child.style,
rawStyle: child.getAttribute('style'),
}); });
} }
@@ -409,8 +468,8 @@ function getCSSLayoutStyle(node) {
'height', 'height',
'min-height', 'min-height',
'max-height', 'max-height',
].reduce(function(prev, curr) { ].reduce(function(map, key) {
prev[curr] = getComputedStyle(node, null).getPropertyValue(curr); map[key] = getComputedStyle(node, null).getPropertyValue(key);
return prev; return map;
}, {}); }, {});
} }

View File

@@ -1,5 +1,15 @@
rm $(dirname $0)/test.html rm $(dirname $0)/test.html
$EDITOR $(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 open $(dirname $0)/test.html

View File

@@ -27,18 +27,40 @@
flex-shrink: 0; flex-shrink: 0;
} }
#container > * { body > * {
position: absolute; position: absolute;
} }
#ltr-container > * {
position: absolute;
direction: ltr;
}
#rtl-container > * {
position: absolute;
direction: rtl;
}
</style> </style>
</head> </head>
<body> <body>
<div id='container'> <div id='ltr-container'>
%s %s
<div id='default'></div> <div id='default'></div>
</div> </div>
<div id='rtl-container'>
%s
<div id='default'></div>
</div>
<div>
%s
</div>
</body> </body>
</html> </html>

View File

@@ -10,24 +10,24 @@
/** /**
* @Generated by gentest/gentest.sh with the following input * @Generated by gentest/gentest.sh with the following input
* *
<div id="absolute_layout_width_height_left_top" style="width: 100px; height: 100px;"> <div id="absolute_layout_width_height_start_top" style="width: 100px; height: 100px;">
<div style="width:10px; height: 10px; position: absolute; left: 10px; top: 10px;"></div> <div style="width:10px; height: 10px; position: absolute; start: 10px; top: 10px;"></div>
</div> </div>
<div id="absolute_layout_width_height_right_bottom" style="width: 100px; height: 100px;"> <div id="absolute_layout_width_height_end_bottom" style="width: 100px; height: 100px;">
<div style="width:10px; height: 10px; position: absolute; right: 10px; bottom: 10px;"></div> <div style="width:10px; height: 10px; position: absolute; end: 10px; bottom: 10px;"></div>
</div> </div>
<div id="absolute_layout_left_top_right_bottom" style="width: 100px; height: 100px;"> <div id="absolute_layout_start_top_end_bottom" style="width: 100px; height: 100px;">
<div style="position: absolute; left: 10px; top: 10px; right: 10px; bottom: 10px;"></div> <div style="position: absolute; start: 10px; top: 10px; end: 10px; bottom: 10px;"></div>
</div> </div>
<div id="absolute_layout_width_height_left_top_right_bottom" style="width: 100px; height: 100px;"> <div id="absolute_layout_width_height_start_top_end_bottom" style="width: 100px; height: 100px;">
<div style="width:10px; height: 10px; position: absolute; left: 10px; top: 10px; right: 10px; bottom: 10px;"></div> <div style="width:10px; height: 10px; position: absolute; start: 10px; top: 10px; end: 10px; bottom: 10px;"></div>
</div> </div>
<div id="do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent" style="height: 50px; width: 50px; overflow: hidden; flex-direction: row;"> <div id="do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent" style="height: 50px; width: 50px; overflow: hidden; flex-direction: row;">
<div style="position: absolute; left: 0; top: 0;"> <div style="position: absolute; start: 0; top: 0;">
<div style="width: 100px; height: 100px;"></div> <div style="width: 100px; height: 100px;"></div>
</div> </div>
</div> </div>
@@ -37,14 +37,14 @@
#include <CSSLayout/CSSLayout.h> #include <CSSLayout/CSSLayout.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
TEST(CSSLayoutTest, absolute_layout_width_height_left_top) { TEST(CSSLayoutTest, absolute_layout_width_height_start_top) {
const CSSNodeRef root = CSSNodeNew(); const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100); CSSNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew(); const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetPositionType(root_child0, CSSPositionTypeAbsolute); CSSNodeStyleSetPositionType(root_child0, CSSPositionTypeAbsolute);
CSSNodeStyleSetPosition(root_child0, CSSEdgeLeft, 10); CSSNodeStyleSetPosition(root_child0, CSSEdgeStart, 10);
CSSNodeStyleSetPosition(root_child0, CSSEdgeTop, 10); CSSNodeStyleSetPosition(root_child0, CSSEdgeTop, 10);
CSSNodeStyleSetWidth(root_child0, 10); CSSNodeStyleSetWidth(root_child0, 10);
CSSNodeStyleSetHeight(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, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(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(); const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100); CSSNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew(); const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetPositionType(root_child0, CSSPositionTypeAbsolute); CSSNodeStyleSetPositionType(root_child0, CSSPositionTypeAbsolute);
CSSNodeStyleSetPosition(root_child0, CSSEdgeRight, 10); CSSNodeStyleSetPosition(root_child0, CSSEdgeEnd, 10);
CSSNodeStyleSetPosition(root_child0, CSSEdgeBottom, 10); CSSNodeStyleSetPosition(root_child0, CSSEdgeBottom, 10);
CSSNodeStyleSetWidth(root_child0, 10); CSSNodeStyleSetWidth(root_child0, 10);
CSSNodeStyleSetHeight(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(80, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(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(); const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100); CSSNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew(); const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetPositionType(root_child0, CSSPositionTypeAbsolute); CSSNodeStyleSetPositionType(root_child0, CSSPositionTypeAbsolute);
CSSNodeStyleSetPosition(root_child0, CSSEdgeLeft, 10); CSSNodeStyleSetPosition(root_child0, CSSEdgeStart, 10);
CSSNodeStyleSetPosition(root_child0, CSSEdgeTop, 10); CSSNodeStyleSetPosition(root_child0, CSSEdgeTop, 10);
CSSNodeStyleSetPosition(root_child0, CSSEdgeRight, 10); CSSNodeStyleSetPosition(root_child0, CSSEdgeEnd, 10);
CSSNodeStyleSetPosition(root_child0, CSSEdgeBottom, 10); CSSNodeStyleSetPosition(root_child0, CSSEdgeBottom, 10);
CSSNodeInsertChild(root, root_child0, 0); CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); 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(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(80, CSSNodeLayoutGetWidth(root_child0)); ASSERT_EQ(80, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(80, CSSNodeLayoutGetHeight(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(); const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100); CSSNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew(); const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetPositionType(root_child0, CSSPositionTypeAbsolute); CSSNodeStyleSetPositionType(root_child0, CSSPositionTypeAbsolute);
CSSNodeStyleSetPosition(root_child0, CSSEdgeLeft, 10); CSSNodeStyleSetPosition(root_child0, CSSEdgeStart, 10);
CSSNodeStyleSetPosition(root_child0, CSSEdgeTop, 10); CSSNodeStyleSetPosition(root_child0, CSSEdgeTop, 10);
CSSNodeStyleSetPosition(root_child0, CSSEdgeRight, 10); CSSNodeStyleSetPosition(root_child0, CSSEdgeEnd, 10);
CSSNodeStyleSetPosition(root_child0, CSSEdgeBottom, 10); CSSNodeStyleSetPosition(root_child0, CSSEdgeBottom, 10);
CSSNodeStyleSetWidth(root_child0, 10); CSSNodeStyleSetWidth(root_child0, 10);
CSSNodeStyleSetHeight(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, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(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) { 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(0, CSSNodeLayoutGetTop(root_child0_child0));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0_child0)); ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0_child0));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(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));
} }

View File

@@ -49,7 +49,6 @@
TEST(CSSLayoutTest, align_content_flex_start) { TEST(CSSLayoutTest, align_content_flex_start) {
const CSSNodeRef root = CSSNodeNew(); const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetAlignContent(root, CSSAlignFlexStart);
CSSNodeStyleSetFlexWrap(root, CSSWrapTypeWrap); CSSNodeStyleSetFlexWrap(root, CSSWrapTypeWrap);
CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100); CSSNodeStyleSetHeight(root, 100);
@@ -109,11 +108,42 @@ TEST(CSSLayoutTest, align_content_flex_start) {
ASSERT_EQ(40, CSSNodeLayoutGetTop(root_child4)); ASSERT_EQ(40, CSSNodeLayoutGetTop(root_child4));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child4)); ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child4));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(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) { TEST(CSSLayoutTest, align_content_flex_end) {
const CSSNodeRef root = CSSNodeNew(); const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetAlignContent(root, CSSAlignFlexEnd);
CSSNodeStyleSetFlexWrap(root, CSSWrapTypeWrap); CSSNodeStyleSetFlexWrap(root, CSSWrapTypeWrap);
CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100); CSSNodeStyleSetHeight(root, 100);
@@ -173,6 +203,38 @@ TEST(CSSLayoutTest, align_content_flex_end) {
ASSERT_EQ(40, CSSNodeLayoutGetTop(root_child4)); ASSERT_EQ(40, CSSNodeLayoutGetTop(root_child4));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child4)); ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child4));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(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) { TEST(CSSLayoutTest, align_content_center) {
@@ -237,6 +299,38 @@ TEST(CSSLayoutTest, align_content_center) {
ASSERT_EQ(40, CSSNodeLayoutGetTop(root_child4)); ASSERT_EQ(40, CSSNodeLayoutGetTop(root_child4));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child4)); ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child4));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(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) { TEST(CSSLayoutTest, align_content_stretch) {
@@ -296,4 +390,36 @@ TEST(CSSLayoutTest, align_content_stretch) {
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child4)); ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child4));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child4)); ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child4));
ASSERT_EQ(0, CSSNodeLayoutGetHeight(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));
} }

View File

@@ -50,6 +50,18 @@ TEST(CSSLayoutTest, align_items_stretch) {
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(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) { TEST(CSSLayoutTest, align_items_center) {
@@ -74,16 +86,26 @@ TEST(CSSLayoutTest, align_items_center) {
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(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) { TEST(CSSLayoutTest, align_items_flex_start) {
const CSSNodeRef root = CSSNodeNew(); const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart);
CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100); CSSNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew(); const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetAlignSelf(root_child0, CSSAlignFlexStart);
CSSNodeStyleSetWidth(root_child0, 10); CSSNodeStyleSetWidth(root_child0, 10);
CSSNodeStyleSetHeight(root_child0, 10); CSSNodeStyleSetHeight(root_child0, 10);
CSSNodeInsertChild(root, root_child0, 0); CSSNodeInsertChild(root, root_child0, 0);
@@ -98,20 +120,42 @@ TEST(CSSLayoutTest, align_items_flex_start) {
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
}
TEST(CSSLayoutTest, align_items_flex_end) { CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL);
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetAlignItems(root, CSSAlignFlexEnd); ASSERT_EQ(0, CSSNodeLayoutGetLeft(root));
CSSNodeStyleSetWidth(root, 100); ASSERT_EQ(0, CSSNodeLayoutGetTop(root));
CSSNodeStyleSetHeight(root, 100); ASSERT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root));
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetAlignSelf(root_child0, CSSAlignFlexEnd); ASSERT_EQ(90, CSSNodeLayoutGetLeft(root_child0));
CSSNodeStyleSetWidth(root_child0, 10); ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
CSSNodeStyleSetHeight(root_child0, 10); ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
CSSNodeInsertChild(root, root_child0, 0); ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); }
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, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_EQ(0, CSSNodeLayoutGetTop(root));

View File

@@ -52,6 +52,18 @@ TEST(CSSLayoutTest, align_self_center) {
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(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) { TEST(CSSLayoutTest, align_self_flex_end) {
@@ -60,7 +72,6 @@ TEST(CSSLayoutTest, align_self_flex_end) {
CSSNodeStyleSetHeight(root, 100); CSSNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew(); const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetAlignSelf(root_child0, CSSAlignFlexEnd);
CSSNodeStyleSetWidth(root_child0, 10); CSSNodeStyleSetWidth(root_child0, 10);
CSSNodeStyleSetHeight(root_child0, 10); CSSNodeStyleSetHeight(root_child0, 10);
CSSNodeInsertChild(root, root_child0, 0); CSSNodeInsertChild(root, root_child0, 0);
@@ -71,6 +82,18 @@ TEST(CSSLayoutTest, align_self_flex_end) {
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(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(90, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
@@ -83,7 +106,6 @@ TEST(CSSLayoutTest, align_self_flex_start) {
CSSNodeStyleSetHeight(root, 100); CSSNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew(); const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetAlignSelf(root_child0, CSSAlignFlexStart);
CSSNodeStyleSetWidth(root_child0, 10); CSSNodeStyleSetWidth(root_child0, 10);
CSSNodeStyleSetHeight(root_child0, 10); CSSNodeStyleSetHeight(root_child0, 10);
CSSNodeInsertChild(root, root_child0, 0); CSSNodeInsertChild(root, root_child0, 0);
@@ -98,20 +120,42 @@ TEST(CSSLayoutTest, align_self_flex_start) {
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
}
TEST(CSSLayoutTest, align_self_flex_end_override_flex_start) { CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL);
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart); ASSERT_EQ(0, CSSNodeLayoutGetLeft(root));
CSSNodeStyleSetWidth(root, 100); ASSERT_EQ(0, CSSNodeLayoutGetTop(root));
CSSNodeStyleSetHeight(root, 100); ASSERT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root));
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetAlignSelf(root_child0, CSSAlignFlexEnd); ASSERT_EQ(90, CSSNodeLayoutGetLeft(root_child0));
CSSNodeStyleSetWidth(root_child0, 10); ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
CSSNodeStyleSetHeight(root_child0, 10); ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
CSSNodeInsertChild(root, root_child0, 0); ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); }
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, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_EQ(0, CSSNodeLayoutGetTop(root));

View File

@@ -25,7 +25,7 @@
<div style="height: 10px;"></div> <div style="height: 10px;"></div>
</div> </div>
<div id="border_center_child" style="width: 100px; height: 100px; border-left-width: 10px; border-top-width: 10; border-right-width: 20px; border-bottom-width: 20px; align-items: center; justify-content: center;"> <div id="border_center_child" style="width: 100px; height: 100px; border-start-width: 10px; border-top-width: 10; border-end-width: 20px; border-bottom-width: 20px; align-items: center; justify-content: center;">
<div style="height: 10px; width: 10px;"></div> <div style="height: 10px; width: 10px;"></div>
</div> </div>
* *
@@ -46,6 +46,13 @@ TEST(CSSLayoutTest, border_no_size) {
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(20, CSSNodeLayoutGetWidth(root)); ASSERT_EQ(20, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(20, CSSNodeLayoutGetHeight(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) { 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, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(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) { TEST(CSSLayoutTest, border_flex_child) {
@@ -96,6 +115,18 @@ TEST(CSSLayoutTest, border_flex_child) {
ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(80, CSSNodeLayoutGetHeight(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) { TEST(CSSLayoutTest, border_stretch_child) {
@@ -121,14 +152,26 @@ TEST(CSSLayoutTest, border_stretch_child) {
ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(80, CSSNodeLayoutGetWidth(root_child0)); ASSERT_EQ(80, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(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) { TEST(CSSLayoutTest, border_center_child) {
const CSSNodeRef root = CSSNodeNew(); const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetJustifyContent(root, CSSJustifyCenter); CSSNodeStyleSetJustifyContent(root, CSSJustifyCenter);
CSSNodeStyleSetAlignItems(root, CSSAlignCenter); CSSNodeStyleSetAlignItems(root, CSSAlignCenter);
CSSNodeStyleSetBorder(root, CSSEdgeLeft, 10); CSSNodeStyleSetBorder(root, CSSEdgeStart, 10);
CSSNodeStyleSetBorder(root, CSSEdgeRight, 20); CSSNodeStyleSetBorder(root, CSSEdgeEnd, 20);
CSSNodeStyleSetBorder(root, CSSEdgeBottom, 20); CSSNodeStyleSetBorder(root, CSSEdgeBottom, 20);
CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100); CSSNodeStyleSetHeight(root, 100);
@@ -149,4 +192,16 @@ TEST(CSSLayoutTest, border_center_child) {
ASSERT_EQ(35, CSSNodeLayoutGetTop(root_child0)); ASSERT_EQ(35, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(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));
} }

View File

@@ -87,6 +87,28 @@ TEST(CSSLayoutTest, flex_direction_column_no_height) {
ASSERT_EQ(20, CSSNodeLayoutGetTop(root_child2)); ASSERT_EQ(20, CSSNodeLayoutGetTop(root_child2));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(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) { 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(0, CSSNodeLayoutGetTop(root_child2));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(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) { TEST(CSSLayoutTest, flex_direction_column) {
@@ -165,6 +209,28 @@ TEST(CSSLayoutTest, flex_direction_column) {
ASSERT_EQ(20, CSSNodeLayoutGetTop(root_child2)); ASSERT_EQ(20, CSSNodeLayoutGetTop(root_child2));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(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) { TEST(CSSLayoutTest, flex_direction_row) {
@@ -205,6 +271,28 @@ TEST(CSSLayoutTest, flex_direction_row) {
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2)); ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(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) { TEST(CSSLayoutTest, flex_direction_column_reverse) {
@@ -245,6 +333,28 @@ TEST(CSSLayoutTest, flex_direction_column_reverse) {
ASSERT_EQ(70, CSSNodeLayoutGetTop(root_child2)); ASSERT_EQ(70, CSSNodeLayoutGetTop(root_child2));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(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) { TEST(CSSLayoutTest, flex_direction_row_reverse) {
@@ -285,4 +395,26 @@ TEST(CSSLayoutTest, flex_direction_row_reverse) {
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2)); ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(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));
} }

View File

@@ -29,11 +29,6 @@
<div style="flex-basis: 100px; flex-shrink: 1;"></div> <div style="flex-basis: 100px; flex-shrink: 1;"></div>
<div style="flex-basis: 50px;"></div> <div style="flex-basis: 50px;"></div>
</div> </div>
<div id="flex_basis_flex_grow_undefined_main" style="width: 100px;">
<div style="flex-basis: 100px; flex-grow: 1;"></div>
<div style="flex-basis: 50px;"></div>
</div>
* *
*/ */
@@ -69,6 +64,23 @@ TEST(CSSLayoutTest, flex_basis_flex_grow_column) {
ASSERT_EQ(75, CSSNodeLayoutGetTop(root_child1)); ASSERT_EQ(75, CSSNodeLayoutGetTop(root_child1));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child1));
ASSERT_EQ(25, CSSNodeLayoutGetHeight(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) { 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(0, CSSNodeLayoutGetTop(root_child1));
ASSERT_EQ(25, CSSNodeLayoutGetWidth(root_child1)); ASSERT_EQ(25, CSSNodeLayoutGetWidth(root_child1));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(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) { 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(50, CSSNodeLayoutGetTop(root_child1));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child1));
ASSERT_EQ(50, CSSNodeLayoutGetHeight(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) { 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(0, CSSNodeLayoutGetTop(root_child1));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child1));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(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));
} }

View File

@@ -40,25 +40,21 @@ TEST(CSSLayoutTest, wrap_column) {
CSSNodeStyleSetHeight(root, 100); CSSNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew(); const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetAlignSelf(root_child0, CSSAlignStretch);
CSSNodeStyleSetWidth(root_child0, 30); CSSNodeStyleSetWidth(root_child0, 30);
CSSNodeStyleSetHeight(root_child0, 30); CSSNodeStyleSetHeight(root_child0, 30);
CSSNodeInsertChild(root, root_child0, 0); CSSNodeInsertChild(root, root_child0, 0);
const CSSNodeRef root_child1 = CSSNodeNew(); const CSSNodeRef root_child1 = CSSNodeNew();
CSSNodeStyleSetAlignSelf(root_child1, CSSAlignStretch);
CSSNodeStyleSetWidth(root_child1, 30); CSSNodeStyleSetWidth(root_child1, 30);
CSSNodeStyleSetHeight(root_child1, 30); CSSNodeStyleSetHeight(root_child1, 30);
CSSNodeInsertChild(root, root_child1, 1); CSSNodeInsertChild(root, root_child1, 1);
const CSSNodeRef root_child2 = CSSNodeNew(); const CSSNodeRef root_child2 = CSSNodeNew();
CSSNodeStyleSetAlignSelf(root_child2, CSSAlignStretch);
CSSNodeStyleSetWidth(root_child2, 30); CSSNodeStyleSetWidth(root_child2, 30);
CSSNodeStyleSetHeight(root_child2, 30); CSSNodeStyleSetHeight(root_child2, 30);
CSSNodeInsertChild(root, root_child2, 2); CSSNodeInsertChild(root, root_child2, 2);
const CSSNodeRef root_child3 = CSSNodeNew(); const CSSNodeRef root_child3 = CSSNodeNew();
CSSNodeStyleSetAlignSelf(root_child3, CSSAlignStretch);
CSSNodeStyleSetWidth(root_child3, 30); CSSNodeStyleSetWidth(root_child3, 30);
CSSNodeStyleSetHeight(root_child3, 30); CSSNodeStyleSetHeight(root_child3, 30);
CSSNodeInsertChild(root, root_child3, 3); CSSNodeInsertChild(root, root_child3, 3);
@@ -88,6 +84,33 @@ TEST(CSSLayoutTest, wrap_column) {
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child3)); ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child3));
ASSERT_EQ(30, CSSNodeLayoutGetWidth(root_child3)); ASSERT_EQ(30, CSSNodeLayoutGetWidth(root_child3));
ASSERT_EQ(30, CSSNodeLayoutGetHeight(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) { TEST(CSSLayoutTest, wrap_row) {
@@ -97,25 +120,21 @@ TEST(CSSLayoutTest, wrap_row) {
CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetWidth(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew(); const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetAlignSelf(root_child0, CSSAlignStretch);
CSSNodeStyleSetWidth(root_child0, 30); CSSNodeStyleSetWidth(root_child0, 30);
CSSNodeStyleSetHeight(root_child0, 30); CSSNodeStyleSetHeight(root_child0, 30);
CSSNodeInsertChild(root, root_child0, 0); CSSNodeInsertChild(root, root_child0, 0);
const CSSNodeRef root_child1 = CSSNodeNew(); const CSSNodeRef root_child1 = CSSNodeNew();
CSSNodeStyleSetAlignSelf(root_child1, CSSAlignStretch);
CSSNodeStyleSetWidth(root_child1, 30); CSSNodeStyleSetWidth(root_child1, 30);
CSSNodeStyleSetHeight(root_child1, 30); CSSNodeStyleSetHeight(root_child1, 30);
CSSNodeInsertChild(root, root_child1, 1); CSSNodeInsertChild(root, root_child1, 1);
const CSSNodeRef root_child2 = CSSNodeNew(); const CSSNodeRef root_child2 = CSSNodeNew();
CSSNodeStyleSetAlignSelf(root_child2, CSSAlignStretch);
CSSNodeStyleSetWidth(root_child2, 30); CSSNodeStyleSetWidth(root_child2, 30);
CSSNodeStyleSetHeight(root_child2, 30); CSSNodeStyleSetHeight(root_child2, 30);
CSSNodeInsertChild(root, root_child2, 2); CSSNodeInsertChild(root, root_child2, 2);
const CSSNodeRef root_child3 = CSSNodeNew(); const CSSNodeRef root_child3 = CSSNodeNew();
CSSNodeStyleSetAlignSelf(root_child3, CSSAlignStretch);
CSSNodeStyleSetWidth(root_child3, 30); CSSNodeStyleSetWidth(root_child3, 30);
CSSNodeStyleSetHeight(root_child3, 30); CSSNodeStyleSetHeight(root_child3, 30);
CSSNodeInsertChild(root, root_child3, 3); CSSNodeInsertChild(root, root_child3, 3);
@@ -145,4 +164,31 @@ TEST(CSSLayoutTest, wrap_row) {
ASSERT_EQ(30, CSSNodeLayoutGetTop(root_child3)); ASSERT_EQ(30, CSSNodeLayoutGetTop(root_child3));
ASSERT_EQ(30, CSSNodeLayoutGetWidth(root_child3)); ASSERT_EQ(30, CSSNodeLayoutGetWidth(root_child3));
ASSERT_EQ(30, CSSNodeLayoutGetHeight(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));
} }

View File

@@ -113,12 +113,33 @@ TEST(CSSLayoutTest, justify_content_row_flex_start) {
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2)); ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(102, CSSNodeLayoutGetHeight(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) { TEST(CSSLayoutTest, justify_content_row_flex_end) {
const CSSNodeRef root = CSSNodeNew(); const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionRow); CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionRow);
CSSNodeStyleSetJustifyContent(root, CSSJustifyFlexEnd);
CSSNodeStyleSetWidth(root, 102); CSSNodeStyleSetWidth(root, 102);
CSSNodeStyleSetHeight(root, 102); CSSNodeStyleSetHeight(root, 102);
@@ -140,7 +161,29 @@ TEST(CSSLayoutTest, justify_content_row_flex_end) {
ASSERT_EQ(102, CSSNodeLayoutGetWidth(root)); ASSERT_EQ(102, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(102, CSSNodeLayoutGetHeight(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(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(102, CSSNodeLayoutGetHeight(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(10, CSSNodeLayoutGetWidth(root_child1));
ASSERT_EQ(102, CSSNodeLayoutGetHeight(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(0, CSSNodeLayoutGetTop(root_child2));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(102, CSSNodeLayoutGetHeight(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(0, CSSNodeLayoutGetTop(root_child2));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(102, CSSNodeLayoutGetHeight(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) { 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(0, CSSNodeLayoutGetTop(root_child2));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(102, CSSNodeLayoutGetHeight(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) { 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(0, CSSNodeLayoutGetTop(root_child2));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(102, CSSNodeLayoutGetHeight(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) { 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(10, CSSNodeLayoutGetTop(root_child2));
ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child2)); ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(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) { TEST(CSSLayoutTest, justify_content_column_flex_end) {
const CSSNodeRef root = CSSNodeNew(); const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetJustifyContent(root, CSSJustifyFlexEnd);
CSSNodeStyleSetWidth(root, 102); CSSNodeStyleSetWidth(root, 102);
CSSNodeStyleSetHeight(root, 102); CSSNodeStyleSetHeight(root, 102);
@@ -342,17 +472,39 @@ TEST(CSSLayoutTest, justify_content_column_flex_end) {
ASSERT_EQ(102, CSSNodeLayoutGetHeight(root)); ASSERT_EQ(102, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); 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(102, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); 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(102, CSSNodeLayoutGetWidth(root_child1));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child1));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); 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(102, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(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(56, CSSNodeLayoutGetTop(root_child2));
ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child2)); ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(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) { 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(92, CSSNodeLayoutGetTop(root_child2));
ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child2)); ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(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) { 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(80, CSSNodeLayoutGetTop(root_child2));
ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child2)); ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(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));
} }

View File

@@ -10,16 +10,16 @@
/** /**
* @Generated by gentest/gentest.sh with the following input * @Generated by gentest/gentest.sh with the following input
* *
<div id="margin_left" style="width: 100px; height: 100px; flex-direction: row;"> <div id="margin_start" style="width: 100px; height: 100px; flex-direction: row;">
<div style="width: 10px; margin-left: 10px;"></div> <div style="width: 10px; margin-start: 10px;"></div>
</div> </div>
<div id="margin_top" style="width: 100px; height: 100px;"> <div id="margin_top" style="width: 100px; height: 100px;">
<div style="height: 10px; margin-top: 10px;"></div> <div style="height: 10px; margin-top: 10px;"></div>
</div> </div>
<div id="margin_right" style="width: 100px; height: 100px; flex-direction: row; justify-content: flex-end;"> <div id="margin_end" style="width: 100px; height: 100px; flex-direction: row; justify-content: flex-end;">
<div style="width: 10px; margin-right: 10px;"></div> <div style="width: 10px; margin-end: 10px;"></div>
</div> </div>
<div id="margin_bottom" style="width: 100px; height: 100px; justify-content: flex-end;"> <div id="margin_bottom" style="width: 100px; height: 100px; justify-content: flex-end;">
@@ -27,7 +27,7 @@
</div> </div>
<div id="margin_and_flex_row" style="width: 100px; height: 100px; flex-direction: row;"> <div id="margin_and_flex_row" style="width: 100px; height: 100px; flex-direction: row;">
<div style="margin-left: 10px; margin-right; 10px; flex-grow: 1;"></div> <div style="margin-start: 10px; margin-end; 10px; flex-grow: 1;"></div>
</div> </div>
<div id="margin_and_flex_column" style="width: 100px; height: 100px;"> <div id="margin_and_flex_column" style="width: 100px; height: 100px;">
@@ -39,11 +39,11 @@
</div> </div>
<div id="margin_and_stretch_column" style="width: 100px; height: 100px;"> <div id="margin_and_stretch_column" style="width: 100px; height: 100px;">
<div style="margin-left: 10px; margin-right; 10px; flex-grow: 1;"></div> <div style="margin-start: 10px; margin-end; 10px; flex-grow: 1;"></div>
</div> </div>
<div id="margin_with_sibling_row" style="width: 100px; height: 100px; flex-direction: row;"> <div id="margin_with_sibling_row" style="width: 100px; height: 100px; flex-direction: row;">
<div style="margin-right; 10px; flex-grow: 1;"></div> <div style="margin-end; 10px; flex-grow: 1;"></div>
<div style="flex-grow: 1;"></div> <div style="flex-grow: 1;"></div>
</div> </div>
@@ -57,14 +57,14 @@
#include <CSSLayout/CSSLayout.h> #include <CSSLayout/CSSLayout.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
TEST(CSSLayoutTest, margin_left) { TEST(CSSLayoutTest, margin_start) {
const CSSNodeRef root = CSSNodeNew(); const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionRow); CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionRow);
CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100); CSSNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew(); const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetMargin(root_child0, CSSEdgeLeft, 10); CSSNodeStyleSetMargin(root_child0, CSSEdgeStart, 10);
CSSNodeStyleSetWidth(root_child0, 10); CSSNodeStyleSetWidth(root_child0, 10);
CSSNodeInsertChild(root, root_child0, 0); CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
@@ -78,6 +78,18 @@ TEST(CSSLayoutTest, margin_left) {
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(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) { TEST(CSSLayoutTest, margin_top) {
@@ -100,17 +112,28 @@ TEST(CSSLayoutTest, margin_top) {
ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(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(); const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionRow); CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionRow);
CSSNodeStyleSetJustifyContent(root, CSSJustifyFlexEnd);
CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100); CSSNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew(); const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetMargin(root_child0, CSSEdgeRight, 10); CSSNodeStyleSetMargin(root_child0, CSSEdgeEnd, 10);
CSSNodeStyleSetWidth(root_child0, 10); CSSNodeStyleSetWidth(root_child0, 10);
CSSNodeInsertChild(root, root_child0, 0); CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
@@ -120,7 +143,19 @@ TEST(CSSLayoutTest, margin_right) {
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(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(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0));
@@ -128,7 +163,6 @@ TEST(CSSLayoutTest, margin_right) {
TEST(CSSLayoutTest, margin_bottom) { TEST(CSSLayoutTest, margin_bottom) {
const CSSNodeRef root = CSSNodeNew(); const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetJustifyContent(root, CSSJustifyFlexEnd);
CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100); CSSNodeStyleSetHeight(root, 100);
@@ -144,7 +178,19 @@ TEST(CSSLayoutTest, margin_bottom) {
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); 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(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
} }
@@ -157,7 +203,7 @@ TEST(CSSLayoutTest, margin_and_flex_row) {
const CSSNodeRef root_child0 = CSSNodeNew(); const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetFlexGrow(root_child0, 1); CSSNodeStyleSetFlexGrow(root_child0, 1);
CSSNodeStyleSetMargin(root_child0, CSSEdgeLeft, 10); CSSNodeStyleSetMargin(root_child0, CSSEdgeStart, 10);
CSSNodeInsertChild(root, root_child0, 0); CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
@@ -170,6 +216,18 @@ TEST(CSSLayoutTest, margin_and_flex_row) {
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(90, CSSNodeLayoutGetWidth(root_child0)); ASSERT_EQ(90, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(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) { TEST(CSSLayoutTest, margin_and_flex_column) {
@@ -192,6 +250,18 @@ TEST(CSSLayoutTest, margin_and_flex_column) {
ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(90, CSSNodeLayoutGetHeight(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) { TEST(CSSLayoutTest, margin_and_stretch_row) {
@@ -215,6 +285,18 @@ TEST(CSSLayoutTest, margin_and_stretch_row) {
ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(90, CSSNodeLayoutGetHeight(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) { TEST(CSSLayoutTest, margin_and_stretch_column) {
@@ -224,7 +306,7 @@ TEST(CSSLayoutTest, margin_and_stretch_column) {
const CSSNodeRef root_child0 = CSSNodeNew(); const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetFlexGrow(root_child0, 1); CSSNodeStyleSetFlexGrow(root_child0, 1);
CSSNodeStyleSetMargin(root_child0, CSSEdgeLeft, 10); CSSNodeStyleSetMargin(root_child0, CSSEdgeStart, 10);
CSSNodeInsertChild(root, root_child0, 0); CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
@@ -237,6 +319,18 @@ TEST(CSSLayoutTest, margin_and_stretch_column) {
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(90, CSSNodeLayoutGetWidth(root_child0)); ASSERT_EQ(90, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(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) { TEST(CSSLayoutTest, margin_with_sibling_row) {
@@ -268,6 +362,23 @@ TEST(CSSLayoutTest, margin_with_sibling_row) {
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child1));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(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) { TEST(CSSLayoutTest, margin_with_sibling_column) {
@@ -298,4 +409,21 @@ TEST(CSSLayoutTest, margin_with_sibling_column) {
ASSERT_EQ(50, CSSNodeLayoutGetTop(root_child1)); ASSERT_EQ(50, CSSNodeLayoutGetTop(root_child1));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child1));
ASSERT_EQ(50, CSSNodeLayoutGetHeight(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));
} }

View File

@@ -53,6 +53,18 @@ TEST(CSSLayoutTest, max_width) {
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(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) { TEST(CSSLayoutTest, max_height) {
@@ -76,6 +88,18 @@ TEST(CSSLayoutTest, max_height) {
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetHeight(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) { TEST(CSSLayoutTest, min_height) {
@@ -107,6 +131,23 @@ TEST(CSSLayoutTest, min_height) {
ASSERT_EQ(80, CSSNodeLayoutGetTop(root_child1)); ASSERT_EQ(80, CSSNodeLayoutGetTop(root_child1));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child1));
ASSERT_EQ(20, CSSNodeLayoutGetHeight(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) { TEST(CSSLayoutTest, min_width) {
@@ -139,4 +180,21 @@ TEST(CSSLayoutTest, min_width) {
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1));
ASSERT_EQ(20, CSSNodeLayoutGetWidth(root_child1)); ASSERT_EQ(20, CSSNodeLayoutGetWidth(root_child1));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(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));
} }

View File

@@ -25,7 +25,7 @@
<div style="height: 10px;"></div> <div style="height: 10px;"></div>
</div> </div>
<div id="padding_center_child" style="width: 100px; height: 100px; padding-left: 10px; padding-top: 10; padding-right: 20px; padding-bottom: 20px; align-items: center; justify-content: center;"> <div id="padding_center_child" style="width: 100px; height: 100px; padding-start: 10px; padding-top: 10; padding-end: 20px; padding-bottom: 20px; align-items: center; justify-content: center;">
<div style="height: 10px; width: 10px;"></div> <div style="height: 10px; width: 10px;"></div>
</div> </div>
* *
@@ -46,6 +46,13 @@ TEST(CSSLayoutTest, padding_no_size) {
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(20, CSSNodeLayoutGetWidth(root)); ASSERT_EQ(20, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(20, CSSNodeLayoutGetHeight(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) { 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, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(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) { TEST(CSSLayoutTest, padding_flex_child) {
@@ -96,6 +115,18 @@ TEST(CSSLayoutTest, padding_flex_child) {
ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(80, CSSNodeLayoutGetHeight(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) { TEST(CSSLayoutTest, padding_stretch_child) {
@@ -121,14 +152,26 @@ TEST(CSSLayoutTest, padding_stretch_child) {
ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(80, CSSNodeLayoutGetWidth(root_child0)); ASSERT_EQ(80, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(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) { TEST(CSSLayoutTest, padding_center_child) {
const CSSNodeRef root = CSSNodeNew(); const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetJustifyContent(root, CSSJustifyCenter); CSSNodeStyleSetJustifyContent(root, CSSJustifyCenter);
CSSNodeStyleSetAlignItems(root, CSSAlignCenter); CSSNodeStyleSetAlignItems(root, CSSAlignCenter);
CSSNodeStyleSetPadding(root, CSSEdgeLeft, 10); CSSNodeStyleSetPadding(root, CSSEdgeStart, 10);
CSSNodeStyleSetPadding(root, CSSEdgeRight, 20); CSSNodeStyleSetPadding(root, CSSEdgeEnd, 20);
CSSNodeStyleSetPadding(root, CSSEdgeBottom, 20); CSSNodeStyleSetPadding(root, CSSEdgeBottom, 20);
CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100); CSSNodeStyleSetHeight(root, 100);
@@ -149,4 +192,16 @@ TEST(CSSLayoutTest, padding_center_child) {
ASSERT_EQ(35, CSSNodeLayoutGetTop(root_child0)); ASSERT_EQ(35, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(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));
} }