2017-01-02 02:22:45 -08:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2014-present, Facebook, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This source code is licensed under the BSD-style license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
|
|
*/
|
|
|
|
|
2017-01-31 09:28:09 -08:00
|
|
|
// @Generated by gentest/gentest.rb from gentest/fixtures/YGMinMaxDimensionTest.html
|
2017-01-02 02:22:45 -08:00
|
|
|
|
|
|
|
var Yoga = Yoga || require("../../sources/entry-" + process.env.TEST_ENTRY);
|
|
|
|
|
|
|
|
it("max_width", function () {
|
2017-03-28 10:28:53 -07:00
|
|
|
var config = Yoga.Config.create();
|
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2017-03-01 09:19:55 -08:00
|
|
|
var root = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root.setWidth(100);
|
|
|
|
root.setHeight(100);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
var root_child0 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child0.setMaxWidth(50);
|
|
|
|
root_child0.setHeight(10);
|
|
|
|
root.insertChild(root_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(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
|
|
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
|
|
|
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
|
|
|
console.assert(50 === root_child0.getComputedWidth(), "50 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
|
|
|
console.assert(10 === root_child0.getComputedHeight(), "10 === root_child0.getComputedHeight() (" + root_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(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
|
|
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(50 === root_child0.getComputedLeft(), "50 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
|
|
|
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
|
|
|
console.assert(50 === root_child0.getComputedWidth(), "50 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
|
|
|
console.assert(10 === root_child0.getComputedHeight(), "10 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
|
|
|
} finally {
|
|
|
|
if (typeof root !== "undefined") {
|
|
|
|
root.freeRecursive();
|
|
|
|
}
|
2017-03-28 10:28:53 -07:00
|
|
|
|
|
|
|
config.free();
|
2017-02-20 05:31:20 -08:00
|
|
|
}
|
2017-01-02 02:22:45 -08:00
|
|
|
});
|
|
|
|
it("max_height", function () {
|
2017-03-28 10:28:53 -07:00
|
|
|
var config = Yoga.Config.create();
|
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2017-03-01 09:19:55 -08:00
|
|
|
var root = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
|
|
|
root.setWidth(100);
|
|
|
|
root.setHeight(100);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
var root_child0 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child0.setWidth(10);
|
|
|
|
root_child0.setMaxHeight(50);
|
|
|
|
root.insertChild(root_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(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
|
|
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
|
|
|
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
|
|
|
console.assert(10 === root_child0.getComputedWidth(), "10 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
|
|
|
console.assert(50 === root_child0.getComputedHeight(), "50 === root_child0.getComputedHeight() (" + root_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(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
|
|
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(90 === root_child0.getComputedLeft(), "90 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
|
|
|
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
|
|
|
console.assert(10 === root_child0.getComputedWidth(), "10 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
|
|
|
console.assert(50 === root_child0.getComputedHeight(), "50 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
|
|
|
} finally {
|
|
|
|
if (typeof root !== "undefined") {
|
|
|
|
root.freeRecursive();
|
|
|
|
}
|
2017-03-28 10:28:53 -07:00
|
|
|
|
|
|
|
config.free();
|
2017-02-20 05:31:20 -08:00
|
|
|
}
|
2017-01-02 02:22:45 -08:00
|
|
|
});
|
|
|
|
it("min_height", function () {
|
2017-03-28 10:28:53 -07:00
|
|
|
var config = Yoga.Config.create();
|
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2017-03-01 09:19:55 -08:00
|
|
|
var root = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root.setWidth(100);
|
|
|
|
root.setHeight(100);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
var root_child0 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child0.setFlexGrow(1);
|
|
|
|
root_child0.setMinHeight(60);
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
var root_child1 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child1.setFlexGrow(1);
|
|
|
|
root.insertChild(root_child1, 1);
|
|
|
|
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(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
|
|
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
|
|
|
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
|
|
|
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
|
|
|
console.assert(80 === root_child0.getComputedHeight(), "80 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
|
|
|
console.assert(80 === root_child1.getComputedTop(), "80 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
|
|
|
console.assert(100 === root_child1.getComputedWidth(), "100 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
|
|
|
console.assert(20 === root_child1.getComputedHeight(), "20 === root_child1.getComputedHeight() (" + root_child1.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(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
|
|
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
|
|
|
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
|
|
|
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
|
|
|
console.assert(80 === root_child0.getComputedHeight(), "80 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
|
|
|
console.assert(80 === root_child1.getComputedTop(), "80 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
|
|
|
console.assert(100 === root_child1.getComputedWidth(), "100 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
|
|
|
console.assert(20 === root_child1.getComputedHeight(), "20 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
|
|
|
} finally {
|
|
|
|
if (typeof root !== "undefined") {
|
|
|
|
root.freeRecursive();
|
|
|
|
}
|
2017-03-28 10:28:53 -07:00
|
|
|
|
|
|
|
config.free();
|
2017-02-20 05:31:20 -08:00
|
|
|
}
|
2017-01-02 02:22:45 -08:00
|
|
|
});
|
|
|
|
it("min_width", function () {
|
2017-03-28 10:28:53 -07:00
|
|
|
var config = Yoga.Config.create();
|
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2017-03-01 09:19:55 -08:00
|
|
|
var root = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
|
|
|
root.setWidth(100);
|
|
|
|
root.setHeight(100);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
var root_child0 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child0.setFlexGrow(1);
|
|
|
|
root_child0.setMinWidth(60);
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
var root_child1 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child1.setFlexGrow(1);
|
|
|
|
root.insertChild(root_child1, 1);
|
|
|
|
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(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
|
|
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
|
|
|
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
|
|
|
console.assert(80 === root_child0.getComputedWidth(), "80 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
|
|
|
console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(80 === root_child1.getComputedLeft(), "80 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
|
|
|
console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
|
|
|
console.assert(20 === root_child1.getComputedWidth(), "20 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
|
|
|
console.assert(100 === root_child1.getComputedHeight(), "100 === root_child1.getComputedHeight() (" + root_child1.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(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
|
|
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(20 === root_child0.getComputedLeft(), "20 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
|
|
|
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
|
|
|
console.assert(80 === root_child0.getComputedWidth(), "80 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
|
|
|
console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
|
|
|
console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
|
|
|
console.assert(20 === root_child1.getComputedWidth(), "20 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
|
|
|
console.assert(100 === root_child1.getComputedHeight(), "100 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
|
|
|
} finally {
|
|
|
|
if (typeof root !== "undefined") {
|
|
|
|
root.freeRecursive();
|
|
|
|
}
|
2017-03-28 10:28:53 -07:00
|
|
|
|
|
|
|
config.free();
|
2017-02-20 05:31:20 -08:00
|
|
|
}
|
2017-01-02 02:22:45 -08:00
|
|
|
});
|
|
|
|
it("justify_content_min_max", function () {
|
2017-03-28 10:28:53 -07:00
|
|
|
var config = Yoga.Config.create();
|
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2017-03-01 09:19:55 -08:00
|
|
|
var root = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root.setJustifyContent(Yoga.JUSTIFY_CENTER);
|
|
|
|
root.setWidth(100);
|
|
|
|
root.setMinHeight(100);
|
|
|
|
root.setMaxHeight(200);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
var root_child0 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child0.setWidth(60);
|
|
|
|
root_child0.setHeight(60);
|
|
|
|
root.insertChild(root_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(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
|
|
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
|
|
|
console.assert(20 === root_child0.getComputedTop(), "20 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
|
|
|
console.assert(60 === root_child0.getComputedWidth(), "60 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
|
|
|
console.assert(60 === root_child0.getComputedHeight(), "60 === root_child0.getComputedHeight() (" + root_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(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
|
|
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(40 === root_child0.getComputedLeft(), "40 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
|
|
|
console.assert(20 === root_child0.getComputedTop(), "20 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
|
|
|
console.assert(60 === root_child0.getComputedWidth(), "60 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
|
|
|
console.assert(60 === root_child0.getComputedHeight(), "60 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
|
|
|
} finally {
|
|
|
|
if (typeof root !== "undefined") {
|
|
|
|
root.freeRecursive();
|
|
|
|
}
|
2017-03-28 10:28:53 -07:00
|
|
|
|
|
|
|
config.free();
|
2017-02-20 05:31:20 -08:00
|
|
|
}
|
2017-01-02 02:22:45 -08:00
|
|
|
});
|
|
|
|
it("align_items_min_max", function () {
|
2017-03-28 10:28:53 -07:00
|
|
|
var config = Yoga.Config.create();
|
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2017-03-01 09:19:55 -08:00
|
|
|
var root = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root.setAlignItems(Yoga.ALIGN_CENTER);
|
|
|
|
root.setMinWidth(100);
|
|
|
|
root.setMaxWidth(200);
|
|
|
|
root.setHeight(100);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
var root_child0 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child0.setWidth(60);
|
|
|
|
root_child0.setHeight(60);
|
|
|
|
root.insertChild(root_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(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
|
|
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(20 === root_child0.getComputedLeft(), "20 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
|
|
|
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
|
|
|
console.assert(60 === root_child0.getComputedWidth(), "60 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
|
|
|
console.assert(60 === root_child0.getComputedHeight(), "60 === root_child0.getComputedHeight() (" + root_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(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
|
|
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(20 === root_child0.getComputedLeft(), "20 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
|
|
|
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
|
|
|
console.assert(60 === root_child0.getComputedWidth(), "60 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
|
|
|
console.assert(60 === root_child0.getComputedHeight(), "60 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
|
|
|
} finally {
|
|
|
|
if (typeof root !== "undefined") {
|
|
|
|
root.freeRecursive();
|
|
|
|
}
|
2017-03-28 10:28:53 -07:00
|
|
|
|
|
|
|
config.free();
|
2017-02-20 05:31:20 -08:00
|
|
|
}
|
2017-01-02 02:22:45 -08:00
|
|
|
});
|
|
|
|
it("justify_content_overflow_min_max", function () {
|
2017-03-28 10:28:53 -07:00
|
|
|
var config = Yoga.Config.create();
|
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2017-03-01 09:19:55 -08:00
|
|
|
var root = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root.setJustifyContent(Yoga.JUSTIFY_CENTER);
|
|
|
|
root.setMinHeight(100);
|
|
|
|
root.setMaxHeight(110);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
var root_child0 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child0.setWidth(50);
|
|
|
|
root_child0.setHeight(50);
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
var root_child1 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child1.setWidth(50);
|
|
|
|
root_child1.setHeight(50);
|
|
|
|
root.insertChild(root_child1, 1);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
var root_child2 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child2.setWidth(50);
|
|
|
|
root_child2.setHeight(50);
|
|
|
|
root.insertChild(root_child2, 2);
|
|
|
|
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(50 === root.getComputedWidth(), "50 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
|
|
|
console.assert(110 === root.getComputedHeight(), "110 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
|
|
|
console.assert(-20 === root_child0.getComputedTop(), "-20 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
|
|
|
console.assert(50 === root_child0.getComputedWidth(), "50 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
|
|
|
console.assert(50 === root_child0.getComputedHeight(), "50 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
|
|
|
console.assert(30 === root_child1.getComputedTop(), "30 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
|
|
|
console.assert(50 === root_child1.getComputedWidth(), "50 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
|
|
|
console.assert(50 === root_child1.getComputedHeight(), "50 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(0 === root_child2.getComputedLeft(), "0 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")");
|
|
|
|
console.assert(80 === root_child2.getComputedTop(), "80 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")");
|
|
|
|
console.assert(50 === root_child2.getComputedWidth(), "50 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")");
|
|
|
|
console.assert(50 === root_child2.getComputedHeight(), "50 === root_child2.getComputedHeight() (" + root_child2.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(50 === root.getComputedWidth(), "50 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
|
|
|
console.assert(110 === root.getComputedHeight(), "110 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
|
|
|
console.assert(-20 === root_child0.getComputedTop(), "-20 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
|
|
|
console.assert(50 === root_child0.getComputedWidth(), "50 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
|
|
|
console.assert(50 === root_child0.getComputedHeight(), "50 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
|
|
|
console.assert(30 === root_child1.getComputedTop(), "30 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
|
|
|
console.assert(50 === root_child1.getComputedWidth(), "50 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
|
|
|
console.assert(50 === root_child1.getComputedHeight(), "50 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(0 === root_child2.getComputedLeft(), "0 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")");
|
|
|
|
console.assert(80 === root_child2.getComputedTop(), "80 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")");
|
|
|
|
console.assert(50 === root_child2.getComputedWidth(), "50 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")");
|
|
|
|
console.assert(50 === root_child2.getComputedHeight(), "50 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")");
|
|
|
|
} finally {
|
|
|
|
if (typeof root !== "undefined") {
|
|
|
|
root.freeRecursive();
|
|
|
|
}
|
2017-03-28 10:28:53 -07:00
|
|
|
|
|
|
|
config.free();
|
2017-02-20 05:31:20 -08:00
|
|
|
}
|
2017-01-02 02:22:45 -08:00
|
|
|
});
|
2017-02-28 16:27:18 -08:00
|
|
|
it("flex_grow_to_min", function () {
|
2017-03-28 10:28:53 -07:00
|
|
|
var config = Yoga.Config.create();
|
|
|
|
|
2017-04-13 18:01:35 -07:00
|
|
|
config.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_MIN_FLEX_FIX, true);
|
|
|
|
|
2017-02-28 16:27:18 -08:00
|
|
|
try {
|
2017-03-01 09:19:55 -08:00
|
|
|
var root = Yoga.Node.create(config);
|
2017-02-28 16:27:18 -08:00
|
|
|
root.setWidth(100);
|
|
|
|
root.setMinHeight(100);
|
|
|
|
root.setMaxHeight(500);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
var root_child0 = Yoga.Node.create(config);
|
2017-02-28 16:27:18 -08:00
|
|
|
root_child0.setFlexGrow(1);
|
|
|
|
root_child0.setFlexShrink(1);
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
var root_child1 = Yoga.Node.create(config);
|
2017-02-28 16:27:18 -08:00
|
|
|
root_child1.setHeight(50);
|
|
|
|
root.insertChild(root_child1, 1);
|
|
|
|
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(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
|
|
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
|
|
|
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
|
|
|
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
|
|
|
console.assert(50 === root_child0.getComputedHeight(), "50 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
|
|
|
console.assert(50 === root_child1.getComputedTop(), "50 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
|
|
|
console.assert(100 === root_child1.getComputedWidth(), "100 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
|
|
|
console.assert(50 === root_child1.getComputedHeight(), "50 === root_child1.getComputedHeight() (" + root_child1.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(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
|
|
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
|
|
|
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
|
|
|
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
|
|
|
console.assert(50 === root_child0.getComputedHeight(), "50 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
|
|
|
console.assert(50 === root_child1.getComputedTop(), "50 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
|
|
|
console.assert(100 === root_child1.getComputedWidth(), "100 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
|
|
|
console.assert(50 === root_child1.getComputedHeight(), "50 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
|
|
|
} finally {
|
|
|
|
if (typeof root !== "undefined") {
|
|
|
|
root.freeRecursive();
|
|
|
|
}
|
|
|
|
|
2017-03-28 10:28:53 -07:00
|
|
|
config.free();
|
2017-02-28 16:27:18 -08:00
|
|
|
}
|
|
|
|
});
|
2017-04-13 18:01:35 -07:00
|
|
|
it("flex_grow_in_at_most_container", function () {
|
2017-03-28 10:28:53 -07:00
|
|
|
var config = Yoga.Config.create();
|
|
|
|
|
2017-04-13 18:01:35 -07:00
|
|
|
config.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_MIN_FLEX_FIX, true);
|
|
|
|
|
2017-02-28 16:27:18 -08:00
|
|
|
try {
|
2017-03-01 09:19:55 -08:00
|
|
|
var root = Yoga.Node.create(config);
|
2017-02-28 16:27:18 -08:00
|
|
|
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
|
|
|
root.setAlignItems(Yoga.ALIGN_FLEX_START);
|
|
|
|
root.setWidth(100);
|
|
|
|
root.setHeight(100);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
var root_child0 = Yoga.Node.create(config);
|
2017-02-28 16:27:18 -08:00
|
|
|
root_child0.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
var root_child0_child0 = Yoga.Node.create(config);
|
2017-02-28 16:27:18 -08:00
|
|
|
root_child0_child0.setFlexGrow(1);
|
|
|
|
root_child0_child0.setFlexBasis(0);
|
|
|
|
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(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
|
|
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
|
|
|
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
|
|
|
console.assert(0 === root_child0.getComputedWidth(), "0 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
2017-04-13 18:01:35 -07:00
|
|
|
console.assert(0 === root_child0.getComputedHeight(), "0 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
2017-02-28 16:27:18 -08:00
|
|
|
|
|
|
|
console.assert(0 === root_child0_child0.getComputedLeft(), "0 === 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(0 === root_child0_child0.getComputedWidth(), "0 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
|
2017-04-13 18:01:35 -07:00
|
|
|
console.assert(0 === root_child0_child0.getComputedHeight(), "0 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")");
|
2017-02-28 16:27:18 -08:00
|
|
|
|
|
|
|
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(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
|
|
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(100 === root_child0.getComputedLeft(), "100 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
|
|
|
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
|
|
|
console.assert(0 === root_child0.getComputedWidth(), "0 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
2017-04-13 18:01:35 -07:00
|
|
|
console.assert(0 === root_child0.getComputedHeight(), "0 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
2017-02-28 16:27:18 -08:00
|
|
|
|
|
|
|
console.assert(0 === root_child0_child0.getComputedLeft(), "0 === 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(0 === root_child0_child0.getComputedWidth(), "0 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
|
2017-04-13 18:01:35 -07:00
|
|
|
console.assert(0 === root_child0_child0.getComputedHeight(), "0 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")");
|
2017-02-28 16:27:18 -08:00
|
|
|
} finally {
|
|
|
|
if (typeof root !== "undefined") {
|
|
|
|
root.freeRecursive();
|
|
|
|
}
|
|
|
|
|
2017-03-28 10:28:53 -07:00
|
|
|
config.free();
|
2017-02-28 16:27:18 -08:00
|
|
|
}
|
|
|
|
});
|
2017-01-02 02:22:45 -08:00
|
|
|
it("flex_grow_within_max_width", function () {
|
2017-03-28 10:28:53 -07:00
|
|
|
var config = Yoga.Config.create();
|
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2017-03-01 09:19:55 -08:00
|
|
|
var root = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root.setWidth(200);
|
|
|
|
root.setHeight(100);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
var root_child0 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child0.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
|
|
|
root_child0.setMaxWidth(100);
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
var root_child0_child0 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child0_child0.setFlexGrow(1);
|
|
|
|
root_child0_child0.setHeight(20);
|
|
|
|
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(200 === root.getComputedWidth(), "200 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
|
|
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
|
|
|
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
|
|
|
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
|
|
|
console.assert(20 === root_child0.getComputedHeight(), "20 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(0 === root_child0_child0.getComputedLeft(), "0 === 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(100 === root_child0_child0.getComputedWidth(), "100 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
|
|
|
|
console.assert(20 === root_child0_child0.getComputedHeight(), "20 === 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(200 === root.getComputedWidth(), "200 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
|
|
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(100 === root_child0.getComputedLeft(), "100 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
|
|
|
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
|
|
|
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
|
|
|
console.assert(20 === root_child0.getComputedHeight(), "20 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(0 === root_child0_child0.getComputedLeft(), "0 === 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(100 === root_child0_child0.getComputedWidth(), "100 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
|
|
|
|
console.assert(20 === root_child0_child0.getComputedHeight(), "20 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")");
|
|
|
|
} finally {
|
|
|
|
if (typeof root !== "undefined") {
|
|
|
|
root.freeRecursive();
|
|
|
|
}
|
2017-03-28 10:28:53 -07:00
|
|
|
|
|
|
|
config.free();
|
2017-02-20 05:31:20 -08:00
|
|
|
}
|
2017-01-02 02:22:45 -08:00
|
|
|
});
|
|
|
|
it("flex_grow_within_constrained_max_width", function () {
|
2017-03-28 10:28:53 -07:00
|
|
|
var config = Yoga.Config.create();
|
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2017-03-01 09:19:55 -08:00
|
|
|
var root = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root.setWidth(200);
|
|
|
|
root.setHeight(100);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
var root_child0 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child0.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
|
|
|
root_child0.setMaxWidth(300);
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
var root_child0_child0 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child0_child0.setFlexGrow(1);
|
|
|
|
root_child0_child0.setHeight(20);
|
|
|
|
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(200 === root.getComputedWidth(), "200 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
|
|
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
|
|
|
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
|
|
|
console.assert(200 === root_child0.getComputedWidth(), "200 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
|
|
|
console.assert(20 === root_child0.getComputedHeight(), "20 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(0 === root_child0_child0.getComputedLeft(), "0 === 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(200 === root_child0_child0.getComputedWidth(), "200 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
|
|
|
|
console.assert(20 === root_child0_child0.getComputedHeight(), "20 === 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(200 === root.getComputedWidth(), "200 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
|
|
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
|
|
|
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
|
|
|
console.assert(200 === root_child0.getComputedWidth(), "200 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
|
|
|
console.assert(20 === root_child0.getComputedHeight(), "20 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(0 === root_child0_child0.getComputedLeft(), "0 === 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(200 === root_child0_child0.getComputedWidth(), "200 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
|
|
|
|
console.assert(20 === root_child0_child0.getComputedHeight(), "20 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")");
|
|
|
|
} finally {
|
|
|
|
if (typeof root !== "undefined") {
|
|
|
|
root.freeRecursive();
|
|
|
|
}
|
2017-03-28 10:28:53 -07:00
|
|
|
|
|
|
|
config.free();
|
2017-02-20 05:31:20 -08:00
|
|
|
}
|
2017-01-02 02:22:45 -08:00
|
|
|
});
|
|
|
|
it("flex_grow_within_constrained_min_row", function () {
|
2017-03-28 10:28:53 -07:00
|
|
|
var config = Yoga.Config.create();
|
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2017-03-01 09:19:55 -08:00
|
|
|
var root = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
|
|
|
root.setMinWidth(100);
|
|
|
|
root.setHeight(100);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
var root_child0 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child0.setFlexGrow(1);
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
var root_child1 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child1.setWidth(50);
|
|
|
|
root.insertChild(root_child1, 1);
|
|
|
|
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(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
|
|
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
|
|
|
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
|
|
|
console.assert(50 === root_child0.getComputedWidth(), "50 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
|
|
|
console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(50 === root_child1.getComputedLeft(), "50 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
|
|
|
console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
|
|
|
console.assert(50 === root_child1.getComputedWidth(), "50 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
|
|
|
console.assert(100 === root_child1.getComputedHeight(), "100 === root_child1.getComputedHeight() (" + root_child1.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(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
|
|
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(50 === root_child0.getComputedLeft(), "50 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
|
|
|
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
|
|
|
console.assert(50 === root_child0.getComputedWidth(), "50 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
|
|
|
console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
|
|
|
console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
|
|
|
console.assert(50 === root_child1.getComputedWidth(), "50 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
|
|
|
console.assert(100 === root_child1.getComputedHeight(), "100 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
|
|
|
} finally {
|
|
|
|
if (typeof root !== "undefined") {
|
|
|
|
root.freeRecursive();
|
|
|
|
}
|
2017-03-28 10:28:53 -07:00
|
|
|
|
|
|
|
config.free();
|
2017-02-20 05:31:20 -08:00
|
|
|
}
|
2017-01-02 02:22:45 -08:00
|
|
|
});
|
|
|
|
it("flex_grow_within_constrained_min_column", function () {
|
2017-03-28 10:28:53 -07:00
|
|
|
var config = Yoga.Config.create();
|
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2017-03-01 09:19:55 -08:00
|
|
|
var root = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root.setMinHeight(100);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
var root_child0 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child0.setFlexGrow(1);
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
var root_child1 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child1.setHeight(50);
|
|
|
|
root.insertChild(root_child1, 1);
|
|
|
|
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(0 === root.getComputedWidth(), "0 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
|
|
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
|
|
|
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
|
|
|
console.assert(0 === root_child0.getComputedWidth(), "0 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
|
|
|
console.assert(50 === root_child0.getComputedHeight(), "50 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
|
|
|
console.assert(50 === root_child1.getComputedTop(), "50 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
|
|
|
console.assert(0 === root_child1.getComputedWidth(), "0 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
|
|
|
console.assert(50 === root_child1.getComputedHeight(), "50 === root_child1.getComputedHeight() (" + root_child1.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(0 === root.getComputedWidth(), "0 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
|
|
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
|
|
|
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
|
|
|
console.assert(0 === root_child0.getComputedWidth(), "0 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
|
|
|
console.assert(50 === root_child0.getComputedHeight(), "50 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
|
|
|
console.assert(50 === root_child1.getComputedTop(), "50 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
|
|
|
console.assert(0 === root_child1.getComputedWidth(), "0 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
|
|
|
console.assert(50 === root_child1.getComputedHeight(), "50 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
|
|
|
} finally {
|
|
|
|
if (typeof root !== "undefined") {
|
|
|
|
root.freeRecursive();
|
|
|
|
}
|
2017-03-28 10:28:53 -07:00
|
|
|
|
|
|
|
config.free();
|
2017-02-20 05:31:20 -08:00
|
|
|
}
|
2017-01-02 02:22:45 -08:00
|
|
|
});
|
|
|
|
it("flex_grow_within_constrained_max_row", function () {
|
2017-03-28 10:28:53 -07:00
|
|
|
var config = Yoga.Config.create();
|
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2017-03-01 09:19:55 -08:00
|
|
|
var root = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root.setWidth(200);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
var root_child0 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child0.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
|
|
|
root_child0.setMaxWidth(100);
|
|
|
|
root_child0.setHeight(100);
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
var root_child0_child0 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child0_child0.setFlexShrink(1);
|
|
|
|
root_child0_child0.setFlexBasis(100);
|
|
|
|
root_child0.insertChild(root_child0_child0, 0);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
var root_child0_child1 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child0_child1.setWidth(50);
|
|
|
|
root_child0.insertChild(root_child0_child1, 1);
|
|
|
|
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(200 === root.getComputedWidth(), "200 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
|
|
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
|
|
|
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
|
|
|
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
|
|
|
console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(0 === root_child0_child0.getComputedLeft(), "0 === 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(50 === root_child0_child0.getComputedWidth(), "50 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
|
|
|
|
console.assert(100 === root_child0_child0.getComputedHeight(), "100 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(50 === root_child0_child1.getComputedLeft(), "50 === root_child0_child1.getComputedLeft() (" + root_child0_child1.getComputedLeft() + ")");
|
|
|
|
console.assert(0 === root_child0_child1.getComputedTop(), "0 === root_child0_child1.getComputedTop() (" + root_child0_child1.getComputedTop() + ")");
|
|
|
|
console.assert(50 === root_child0_child1.getComputedWidth(), "50 === root_child0_child1.getComputedWidth() (" + root_child0_child1.getComputedWidth() + ")");
|
|
|
|
console.assert(100 === root_child0_child1.getComputedHeight(), "100 === root_child0_child1.getComputedHeight() (" + root_child0_child1.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(200 === root.getComputedWidth(), "200 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
|
|
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(100 === root_child0.getComputedLeft(), "100 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
|
|
|
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
|
|
|
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
|
|
|
console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(50 === root_child0_child0.getComputedLeft(), "50 === 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(50 === root_child0_child0.getComputedWidth(), "50 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
|
|
|
|
console.assert(100 === root_child0_child0.getComputedHeight(), "100 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(0 === root_child0_child1.getComputedLeft(), "0 === root_child0_child1.getComputedLeft() (" + root_child0_child1.getComputedLeft() + ")");
|
|
|
|
console.assert(0 === root_child0_child1.getComputedTop(), "0 === root_child0_child1.getComputedTop() (" + root_child0_child1.getComputedTop() + ")");
|
|
|
|
console.assert(50 === root_child0_child1.getComputedWidth(), "50 === root_child0_child1.getComputedWidth() (" + root_child0_child1.getComputedWidth() + ")");
|
|
|
|
console.assert(100 === root_child0_child1.getComputedHeight(), "100 === root_child0_child1.getComputedHeight() (" + root_child0_child1.getComputedHeight() + ")");
|
|
|
|
} finally {
|
|
|
|
if (typeof root !== "undefined") {
|
|
|
|
root.freeRecursive();
|
|
|
|
}
|
2017-03-28 10:28:53 -07:00
|
|
|
|
|
|
|
config.free();
|
2017-02-20 05:31:20 -08:00
|
|
|
}
|
2017-01-02 02:22:45 -08:00
|
|
|
});
|
|
|
|
it("flex_grow_within_constrained_max_column", function () {
|
2017-03-28 10:28:53 -07:00
|
|
|
var config = Yoga.Config.create();
|
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2017-03-01 09:19:55 -08:00
|
|
|
var root = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root.setWidth(100);
|
|
|
|
root.setMaxHeight(100);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
var root_child0 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child0.setFlexShrink(1);
|
|
|
|
root_child0.setFlexBasis(100);
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
var root_child1 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child1.setHeight(50);
|
|
|
|
root.insertChild(root_child1, 1);
|
|
|
|
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(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
|
|
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
|
|
|
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
|
|
|
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
|
|
|
console.assert(50 === root_child0.getComputedHeight(), "50 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
|
|
|
console.assert(50 === root_child1.getComputedTop(), "50 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
|
|
|
console.assert(100 === root_child1.getComputedWidth(), "100 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
|
|
|
console.assert(50 === root_child1.getComputedHeight(), "50 === root_child1.getComputedHeight() (" + root_child1.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(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
|
|
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
|
|
|
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
|
|
|
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
|
|
|
console.assert(50 === root_child0.getComputedHeight(), "50 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
|
|
|
console.assert(50 === root_child1.getComputedTop(), "50 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
|
|
|
console.assert(100 === root_child1.getComputedWidth(), "100 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
|
|
|
console.assert(50 === root_child1.getComputedHeight(), "50 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
|
|
|
} finally {
|
|
|
|
if (typeof root !== "undefined") {
|
|
|
|
root.freeRecursive();
|
|
|
|
}
|
2017-03-28 10:28:53 -07:00
|
|
|
|
|
|
|
config.free();
|
2017-02-20 05:31:20 -08:00
|
|
|
}
|
2017-01-02 02:22:45 -08:00
|
|
|
});
|
2017-02-11 05:26:55 -08:00
|
|
|
it("min_width_overrides_width", function () {
|
2017-03-28 10:28:53 -07:00
|
|
|
var config = Yoga.Config.create();
|
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2017-03-01 09:19:55 -08:00
|
|
|
var root = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root.setWidth(50);
|
|
|
|
root.setMinWidth(100);
|
|
|
|
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(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
|
|
|
console.assert(0 === root.getComputedHeight(), "0 === root.getComputedHeight() (" + root.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(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
|
|
|
console.assert(0 === root.getComputedHeight(), "0 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
|
|
|
} finally {
|
|
|
|
if (typeof root !== "undefined") {
|
|
|
|
root.freeRecursive();
|
|
|
|
}
|
2017-03-28 10:28:53 -07:00
|
|
|
|
|
|
|
config.free();
|
2017-02-20 05:31:20 -08:00
|
|
|
}
|
2017-02-11 05:26:55 -08:00
|
|
|
});
|
|
|
|
it("max_width_overrides_width", function () {
|
2017-03-28 10:28:53 -07:00
|
|
|
var config = Yoga.Config.create();
|
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2017-03-01 09:19:55 -08:00
|
|
|
var root = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root.setWidth(200);
|
|
|
|
root.setMaxWidth(100);
|
|
|
|
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(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
|
|
|
console.assert(0 === root.getComputedHeight(), "0 === root.getComputedHeight() (" + root.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(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
|
|
|
console.assert(0 === root.getComputedHeight(), "0 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
|
|
|
} finally {
|
|
|
|
if (typeof root !== "undefined") {
|
|
|
|
root.freeRecursive();
|
|
|
|
}
|
2017-03-28 10:28:53 -07:00
|
|
|
|
|
|
|
config.free();
|
2017-02-20 05:31:20 -08:00
|
|
|
}
|
2017-02-11 05:26:55 -08:00
|
|
|
});
|
|
|
|
it("min_height_overrides_height", function () {
|
2017-03-28 10:28:53 -07:00
|
|
|
var config = Yoga.Config.create();
|
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2017-03-01 09:19:55 -08:00
|
|
|
var root = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root.setHeight(50);
|
|
|
|
root.setMinHeight(100);
|
|
|
|
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(0 === root.getComputedWidth(), "0 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
|
|
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.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(0 === root.getComputedWidth(), "0 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
|
|
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
|
|
|
} finally {
|
|
|
|
if (typeof root !== "undefined") {
|
|
|
|
root.freeRecursive();
|
|
|
|
}
|
2017-03-28 10:28:53 -07:00
|
|
|
|
|
|
|
config.free();
|
2017-02-20 05:31:20 -08:00
|
|
|
}
|
2017-02-11 05:26:55 -08:00
|
|
|
});
|
|
|
|
it("max_height_overrides_height", function () {
|
2017-03-28 10:28:53 -07:00
|
|
|
var config = Yoga.Config.create();
|
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2017-03-01 09:19:55 -08:00
|
|
|
var root = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root.setHeight(200);
|
|
|
|
root.setMaxHeight(100);
|
|
|
|
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(0 === root.getComputedWidth(), "0 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
|
|
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.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(0 === root.getComputedWidth(), "0 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
|
|
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
|
|
|
} finally {
|
|
|
|
if (typeof root !== "undefined") {
|
|
|
|
root.freeRecursive();
|
|
|
|
}
|
2017-03-28 10:28:53 -07:00
|
|
|
|
|
|
|
config.free();
|
2017-02-20 05:31:20 -08:00
|
|
|
}
|
2017-02-11 05:26:55 -08:00
|
|
|
});
|
|
|
|
it("min_max_percent_no_width_height", function () {
|
2017-03-28 10:28:53 -07:00
|
|
|
var config = Yoga.Config.create();
|
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2017-03-01 09:19:55 -08:00
|
|
|
var root = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root.setAlignItems(Yoga.ALIGN_FLEX_START);
|
|
|
|
root.setWidth(100);
|
|
|
|
root.setHeight(100);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
var root_child0 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child0.setMinWidth("10%");
|
|
|
|
root_child0.setMaxWidth("10%");
|
|
|
|
root_child0.setMinHeight("10%");
|
|
|
|
root_child0.setMaxHeight("10%");
|
|
|
|
root.insertChild(root_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(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
|
|
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
|
|
|
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
|
|
|
console.assert(10 === root_child0.getComputedWidth(), "10 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
|
|
|
console.assert(10 === root_child0.getComputedHeight(), "10 === root_child0.getComputedHeight() (" + root_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(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
|
|
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(90 === root_child0.getComputedLeft(), "90 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
|
|
|
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
|
|
|
console.assert(10 === root_child0.getComputedWidth(), "10 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
|
|
|
console.assert(10 === root_child0.getComputedHeight(), "10 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
|
|
|
} finally {
|
|
|
|
if (typeof root !== "undefined") {
|
|
|
|
root.freeRecursive();
|
|
|
|
}
|
2017-03-28 10:28:53 -07:00
|
|
|
|
|
|
|
config.free();
|
2017-02-20 05:31:20 -08:00
|
|
|
}
|
2017-02-11 05:26:55 -08:00
|
|
|
});
|
2017-04-13 18:01:35 -07:00
|
|
|
it("min_width_in_flex_distribution", function () {
|
|
|
|
var config = Yoga.Config.create();
|
|
|
|
|
|
|
|
try {
|
|
|
|
var root = Yoga.Node.create(config);
|
|
|
|
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
|
|
|
root.setWidth(300);
|
|
|
|
root.setHeight(300);
|
|
|
|
|
|
|
|
var root_child0 = Yoga.Node.create(config);
|
|
|
|
root_child0.setFlexGrow(2);
|
|
|
|
root_child0.setFlexShrink(1);
|
|
|
|
root_child0.setFlexBasis("0%");
|
|
|
|
root_child0.setMinWidth(100);
|
|
|
|
root_child0.setMaxWidth(200);
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
|
|
|
|
var root_child1 = Yoga.Node.create(config);
|
|
|
|
root_child1.setFlexGrow(1);
|
|
|
|
root_child1.setFlexShrink(1);
|
|
|
|
root_child1.setFlexBasis("0%");
|
|
|
|
root.insertChild(root_child1, 1);
|
|
|
|
|
|
|
|
var root_child2 = Yoga.Node.create(config);
|
|
|
|
root_child2.setFlexGrow(1);
|
|
|
|
root_child2.setFlexShrink(1);
|
|
|
|
root_child2.setFlexBasis("0%");
|
|
|
|
root.insertChild(root_child2, 2);
|
|
|
|
|
|
|
|
var root_child3 = Yoga.Node.create(config);
|
|
|
|
root_child3.setFlexGrow(1);
|
|
|
|
root_child3.setFlexShrink(1);
|
|
|
|
root_child3.setFlexBasis("0%");
|
|
|
|
root.insertChild(root_child3, 3);
|
|
|
|
|
|
|
|
var root_child4 = Yoga.Node.create(config);
|
|
|
|
root_child4.setFlexGrow(1);
|
|
|
|
root_child4.setFlexShrink(1);
|
|
|
|
root_child4.setFlexBasis("0%");
|
|
|
|
root.insertChild(root_child4, 4);
|
|
|
|
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(300 === root.getComputedWidth(), "300 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
|
|
|
console.assert(300 === root.getComputedHeight(), "300 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
|
|
|
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
|
|
|
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
|
|
|
console.assert(300 === root_child0.getComputedHeight(), "300 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(100 === root_child1.getComputedLeft(), "100 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
|
|
|
console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
|
|
|
console.assert(50 === root_child1.getComputedWidth(), "50 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
|
|
|
console.assert(300 === root_child1.getComputedHeight(), "300 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(150 === root_child2.getComputedLeft(), "150 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")");
|
|
|
|
console.assert(0 === root_child2.getComputedTop(), "0 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")");
|
|
|
|
console.assert(50 === root_child2.getComputedWidth(), "50 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")");
|
|
|
|
console.assert(300 === root_child2.getComputedHeight(), "300 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(200 === root_child3.getComputedLeft(), "200 === root_child3.getComputedLeft() (" + root_child3.getComputedLeft() + ")");
|
|
|
|
console.assert(0 === root_child3.getComputedTop(), "0 === root_child3.getComputedTop() (" + root_child3.getComputedTop() + ")");
|
|
|
|
console.assert(50 === root_child3.getComputedWidth(), "50 === root_child3.getComputedWidth() (" + root_child3.getComputedWidth() + ")");
|
|
|
|
console.assert(300 === root_child3.getComputedHeight(), "300 === root_child3.getComputedHeight() (" + root_child3.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(250 === root_child4.getComputedLeft(), "250 === root_child4.getComputedLeft() (" + root_child4.getComputedLeft() + ")");
|
|
|
|
console.assert(0 === root_child4.getComputedTop(), "0 === root_child4.getComputedTop() (" + root_child4.getComputedTop() + ")");
|
|
|
|
console.assert(50 === root_child4.getComputedWidth(), "50 === root_child4.getComputedWidth() (" + root_child4.getComputedWidth() + ")");
|
|
|
|
console.assert(300 === root_child4.getComputedHeight(), "300 === root_child4.getComputedHeight() (" + root_child4.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(300 === root.getComputedWidth(), "300 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
|
|
|
console.assert(300 === root.getComputedHeight(), "300 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(200 === root_child0.getComputedLeft(), "200 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
|
|
|
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
|
|
|
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
|
|
|
console.assert(300 === root_child0.getComputedHeight(), "300 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(150 === root_child1.getComputedLeft(), "150 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
|
|
|
|
console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
|
|
|
|
console.assert(50 === root_child1.getComputedWidth(), "50 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
|
|
|
|
console.assert(300 === root_child1.getComputedHeight(), "300 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(100 === root_child2.getComputedLeft(), "100 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")");
|
|
|
|
console.assert(0 === root_child2.getComputedTop(), "0 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")");
|
|
|
|
console.assert(50 === root_child2.getComputedWidth(), "50 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")");
|
|
|
|
console.assert(300 === root_child2.getComputedHeight(), "300 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(50 === root_child3.getComputedLeft(), "50 === root_child3.getComputedLeft() (" + root_child3.getComputedLeft() + ")");
|
|
|
|
console.assert(0 === root_child3.getComputedTop(), "0 === root_child3.getComputedTop() (" + root_child3.getComputedTop() + ")");
|
|
|
|
console.assert(50 === root_child3.getComputedWidth(), "50 === root_child3.getComputedWidth() (" + root_child3.getComputedWidth() + ")");
|
|
|
|
console.assert(300 === root_child3.getComputedHeight(), "300 === root_child3.getComputedHeight() (" + root_child3.getComputedHeight() + ")");
|
|
|
|
|
|
|
|
console.assert(0 === root_child4.getComputedLeft(), "0 === root_child4.getComputedLeft() (" + root_child4.getComputedLeft() + ")");
|
|
|
|
console.assert(0 === root_child4.getComputedTop(), "0 === root_child4.getComputedTop() (" + root_child4.getComputedTop() + ")");
|
|
|
|
console.assert(50 === root_child4.getComputedWidth(), "50 === root_child4.getComputedWidth() (" + root_child4.getComputedWidth() + ")");
|
|
|
|
console.assert(300 === root_child4.getComputedHeight(), "300 === root_child4.getComputedHeight() (" + root_child4.getComputedHeight() + ")");
|
|
|
|
} finally {
|
|
|
|
if (typeof root !== "undefined") {
|
|
|
|
root.freeRecursive();
|
|
|
|
}
|
|
|
|
|
|
|
|
config.free();
|
|
|
|
}
|
|
|
|
});
|