fix alignment with margin

This commit is contained in:
Lukas Wöhrl
2017-03-12 01:06:02 +01:00
parent a8e6123d47
commit 81be437a8f
6 changed files with 241 additions and 5 deletions

View File

@@ -1562,3 +1562,61 @@ it("align_baseline_multiline_row_and_column", function () {
}
}
});
it("align_items_center_nested", function () {
try {
var root = Yoga.Node.create(config);
root.setJustifyContent(Yoga.JUSTIFY_CENTER);
root.setAlignItems(Yoga.ALIGN_CENTER);
root.setPositionType(Yoga.POSITION_TYPE_ABSOLUTE);
root.setWidth(52);
root.setHeight(52);
var root_child0 = Yoga.Node.create(config);
root_child0.setAlignItems(Yoga.ALIGN_CENTER);
root.insertChild(root_child0, 0);
var root_child0_child0 = Yoga.Node.create(config);
root_child0_child0.setMargin(Yoga.EDGE_LEFT, 10);
root_child0_child0.setMargin(Yoga.EDGE_RIGHT, 10);
root_child0_child0.setWidth(52);
root_child0_child0.setHeight(52);
root_child0.insertChild(root_child0_child0, 0);
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
console.assert(52 === root.getComputedWidth(), "52 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
console.assert(52 === root.getComputedHeight(), "52 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
console.assert(-10 === root_child0.getComputedLeft(), "-10 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
console.assert(72 === root_child0.getComputedWidth(), "72 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
console.assert(52 === root_child0.getComputedHeight(), "52 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
console.assert(10 === root_child0_child0.getComputedLeft(), "10 === root_child0_child0.getComputedLeft() (" + root_child0_child0.getComputedLeft() + ")");
console.assert(0 === root_child0_child0.getComputedTop(), "0 === root_child0_child0.getComputedTop() (" + root_child0_child0.getComputedTop() + ")");
console.assert(52 === root_child0_child0.getComputedWidth(), "52 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
console.assert(52 === root_child0_child0.getComputedHeight(), "52 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")");
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
console.assert(52 === root.getComputedWidth(), "52 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
console.assert(52 === root.getComputedHeight(), "52 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
console.assert(-10 === root_child0.getComputedLeft(), "-10 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
console.assert(72 === root_child0.getComputedWidth(), "72 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
console.assert(52 === root_child0.getComputedHeight(), "52 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
console.assert(10 === root_child0_child0.getComputedLeft(), "10 === root_child0_child0.getComputedLeft() (" + root_child0_child0.getComputedLeft() + ")");
console.assert(0 === root_child0_child0.getComputedTop(), "0 === root_child0_child0.getComputedTop() (" + root_child0_child0.getComputedTop() + ")");
console.assert(52 === root_child0_child0.getComputedWidth(), "52 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
console.assert(52 === root_child0_child0.getComputedHeight(), "52 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")");
} finally {
if (typeof root !== "undefined") {
root.freeRecursive();
}
}
});