2017-01-02 02:22:45 -08:00
|
|
|
/**
|
Fix Generation of Tests from Fixtures
Summary:
https://github.com/facebook/yoga/pull/1116 added a change to the test generator "gentests.rb" to support a newer version of chromedriver, along with a change to the enum generator (not touched in this diff) to produce code consistent with the current tests, which seem to have been manually edited since last generation.
I had trouble running the test generator locally, because it relies on unversioned third-party dependencies, whose APIs change. Looking at source history, it seems like each time someone wants to run the script, they end up updating its syntax to match whatever versions they pull in.
This change adds a Gemfile and lock so that that the version of "watir" is locked, and so that we will also automatically pull in a consistent "chomedriver" version via the "webdrivers" gem. It includes the updates from the PR to be consistent with already output tests, and I have also updated the copyright header generation to no longer create lint warnings on newly generated tests (some of the previous ones were fixed manually it looks like).
The test generator would still produce bodies which would fail clang-format, and were manually edited (causing generation to emit new lint warnings), so I updated the generator to suppress clang-format in the body of the generated files.
Three tests, around the interaction of minimum dimensions and flexible children produce different results in Chrome now compared to when the tests were added, so running `gentests.rb` creates tests which break UTs. This doesn't seem like any sort of rounding, or device specific difference, so I have disabled these tests for now. While digging around, it does look like Chrome periodically will fix bugs in its own layout implementation which cause differences, like https://bugs.chromium.org/p/chromium/issues/detail?id=927066
Reviewed By: rozele, Andrey-Mishanin
Differential Revision: D39907416
fbshipit-source-id: f88714ff038b42f935901783452df25eabb6ebb1
2022-09-29 22:25:24 -07:00
|
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
2017-01-02 02:22:45 -08:00
|
|
|
*
|
Fix Generation of Tests from Fixtures
Summary:
https://github.com/facebook/yoga/pull/1116 added a change to the test generator "gentests.rb" to support a newer version of chromedriver, along with a change to the enum generator (not touched in this diff) to produce code consistent with the current tests, which seem to have been manually edited since last generation.
I had trouble running the test generator locally, because it relies on unversioned third-party dependencies, whose APIs change. Looking at source history, it seems like each time someone wants to run the script, they end up updating its syntax to match whatever versions they pull in.
This change adds a Gemfile and lock so that that the version of "watir" is locked, and so that we will also automatically pull in a consistent "chomedriver" version via the "webdrivers" gem. It includes the updates from the PR to be consistent with already output tests, and I have also updated the copyright header generation to no longer create lint warnings on newly generated tests (some of the previous ones were fixed manually it looks like).
The test generator would still produce bodies which would fail clang-format, and were manually edited (causing generation to emit new lint warnings), so I updated the generator to suppress clang-format in the body of the generated files.
Three tests, around the interaction of minimum dimensions and flexible children produce different results in Chrome now compared to when the tests were added, so running `gentests.rb` creates tests which break UTs. This doesn't seem like any sort of rounding, or device specific difference, so I have disabled these tests for now. While digging around, it does look like Chrome periodically will fix bugs in its own layout implementation which cause differences, like https://bugs.chromium.org/p/chromium/issues/detail?id=927066
Reviewed By: rozele, Andrey-Mishanin
Differential Revision: D39907416
fbshipit-source-id: f88714ff038b42f935901783452df25eabb6ebb1
2022-09-29 22:25:24 -07:00
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
2017-01-02 02:22:45 -08:00
|
|
|
*/
|
Fix Generation of Tests from Fixtures
Summary:
https://github.com/facebook/yoga/pull/1116 added a change to the test generator "gentests.rb" to support a newer version of chromedriver, along with a change to the enum generator (not touched in this diff) to produce code consistent with the current tests, which seem to have been manually edited since last generation.
I had trouble running the test generator locally, because it relies on unversioned third-party dependencies, whose APIs change. Looking at source history, it seems like each time someone wants to run the script, they end up updating its syntax to match whatever versions they pull in.
This change adds a Gemfile and lock so that that the version of "watir" is locked, and so that we will also automatically pull in a consistent "chomedriver" version via the "webdrivers" gem. It includes the updates from the PR to be consistent with already output tests, and I have also updated the copyright header generation to no longer create lint warnings on newly generated tests (some of the previous ones were fixed manually it looks like).
The test generator would still produce bodies which would fail clang-format, and were manually edited (causing generation to emit new lint warnings), so I updated the generator to suppress clang-format in the body of the generated files.
Three tests, around the interaction of minimum dimensions and flexible children produce different results in Chrome now compared to when the tests were added, so running `gentests.rb` creates tests which break UTs. This doesn't seem like any sort of rounding, or device specific difference, so I have disabled these tests for now. While digging around, it does look like Chrome periodically will fix bugs in its own layout implementation which cause differences, like https://bugs.chromium.org/p/chromium/issues/detail?id=927066
Reviewed By: rozele, Andrey-Mishanin
Differential Revision: D39907416
fbshipit-source-id: f88714ff038b42f935901783452df25eabb6ebb1
2022-09-29 22:25:24 -07:00
|
|
|
|
2022-11-15 19:51:48 -08:00
|
|
|
// @generated by gentest/gentest.rb from gentest/fixtures/YGMarginTest.html
|
2017-01-02 02:22:45 -08:00
|
|
|
|
2022-12-24 02:17:10 -08:00
|
|
|
test("margin_start", () => {
|
2022-12-24 00:35:10 -08:00
|
|
|
const config = Yoga.Config.create();
|
2022-12-24 01:46:20 -08:00
|
|
|
let root;
|
2017-03-28 10:28:53 -07:00
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2022-12-24 01:46:20 -08:00
|
|
|
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);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child0 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child0.setMargin(Yoga.EDGE_START, 10);
|
|
|
|
root_child0.setWidth(10);
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(100);
|
|
|
|
expect(root.getComputedHeight()).toBe(100);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(10);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(10);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(100);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(100);
|
|
|
|
expect(root.getComputedHeight()).toBe(100);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(80);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(10);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(100);
|
2017-02-20 05:31:20 -08:00
|
|
|
} 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
|
|
|
});
|
2022-12-24 02:17:10 -08:00
|
|
|
test("margin_top", () => {
|
2022-12-24 00:35:10 -08:00
|
|
|
const config = Yoga.Config.create();
|
2022-12-24 01:46:20 -08:00
|
|
|
let root;
|
2017-03-28 10:28:53 -07:00
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2022-12-24 01:46:20 -08:00
|
|
|
root = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root.setWidth(100);
|
|
|
|
root.setHeight(100);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child0 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child0.setMargin(Yoga.EDGE_TOP, 10);
|
|
|
|
root_child0.setHeight(10);
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(100);
|
|
|
|
expect(root.getComputedHeight()).toBe(100);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(10);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(100);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(10);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(100);
|
|
|
|
expect(root.getComputedHeight()).toBe(100);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(10);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(100);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(10);
|
2017-02-20 05:31:20 -08:00
|
|
|
} 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
|
|
|
});
|
2022-12-24 02:17:10 -08:00
|
|
|
test("margin_end", () => {
|
2022-12-24 00:35:10 -08:00
|
|
|
const config = Yoga.Config.create();
|
2022-12-24 01:46:20 -08:00
|
|
|
let root;
|
2017-03-28 10:28:53 -07:00
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2022-12-24 01:46:20 -08:00
|
|
|
root = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
|
|
|
root.setJustifyContent(Yoga.JUSTIFY_FLEX_END);
|
|
|
|
root.setWidth(100);
|
|
|
|
root.setHeight(100);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child0 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child0.setMargin(Yoga.EDGE_END, 10);
|
|
|
|
root_child0.setWidth(10);
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(100);
|
|
|
|
expect(root.getComputedHeight()).toBe(100);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(80);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(10);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(100);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(100);
|
|
|
|
expect(root.getComputedHeight()).toBe(100);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(10);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(10);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(100);
|
2017-02-20 05:31:20 -08:00
|
|
|
} 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
|
|
|
});
|
2022-12-24 02:17:10 -08:00
|
|
|
test("margin_bottom", () => {
|
2022-12-24 00:35:10 -08:00
|
|
|
const config = Yoga.Config.create();
|
2022-12-24 01:46:20 -08:00
|
|
|
let root;
|
2017-03-28 10:28:53 -07:00
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2022-12-24 01:46:20 -08:00
|
|
|
root = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root.setJustifyContent(Yoga.JUSTIFY_FLEX_END);
|
|
|
|
root.setWidth(100);
|
|
|
|
root.setHeight(100);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child0 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child0.setMargin(Yoga.EDGE_BOTTOM, 10);
|
|
|
|
root_child0.setHeight(10);
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(100);
|
|
|
|
expect(root.getComputedHeight()).toBe(100);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(80);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(100);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(10);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(100);
|
|
|
|
expect(root.getComputedHeight()).toBe(100);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(80);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(100);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(10);
|
2017-02-20 05:31:20 -08:00
|
|
|
} 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
|
|
|
});
|
2022-12-24 02:17:10 -08:00
|
|
|
test("margin_and_flex_row", () => {
|
2022-12-24 00:35:10 -08:00
|
|
|
const config = Yoga.Config.create();
|
2022-12-24 01:46:20 -08:00
|
|
|
let root;
|
2017-03-28 10:28:53 -07:00
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2022-12-24 01:46:20 -08:00
|
|
|
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);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child0 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child0.setFlexGrow(1);
|
|
|
|
root_child0.setMargin(Yoga.EDGE_START, 10);
|
|
|
|
root_child0.setMargin(Yoga.EDGE_END, 10);
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(100);
|
|
|
|
expect(root.getComputedHeight()).toBe(100);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(10);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(80);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(100);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(100);
|
|
|
|
expect(root.getComputedHeight()).toBe(100);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(10);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(80);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(100);
|
2017-02-20 05:31:20 -08:00
|
|
|
} 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
|
|
|
});
|
2022-12-24 02:17:10 -08:00
|
|
|
test("margin_and_flex_column", () => {
|
2022-12-24 00:35:10 -08:00
|
|
|
const config = Yoga.Config.create();
|
2022-12-24 01:46:20 -08:00
|
|
|
let root;
|
2017-03-28 10:28:53 -07:00
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2022-12-24 01:46:20 -08:00
|
|
|
root = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root.setWidth(100);
|
|
|
|
root.setHeight(100);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child0 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child0.setFlexGrow(1);
|
|
|
|
root_child0.setMargin(Yoga.EDGE_TOP, 10);
|
|
|
|
root_child0.setMargin(Yoga.EDGE_BOTTOM, 10);
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(100);
|
|
|
|
expect(root.getComputedHeight()).toBe(100);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(10);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(100);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(80);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(100);
|
|
|
|
expect(root.getComputedHeight()).toBe(100);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(10);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(100);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(80);
|
2017-02-20 05:31:20 -08:00
|
|
|
} 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
|
|
|
});
|
2022-12-24 02:17:10 -08:00
|
|
|
test("margin_and_stretch_row", () => {
|
2022-12-24 00:35:10 -08:00
|
|
|
const config = Yoga.Config.create();
|
2022-12-24 01:46:20 -08:00
|
|
|
let root;
|
2017-03-28 10:28:53 -07:00
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2022-12-24 01:46:20 -08:00
|
|
|
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);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child0 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child0.setFlexGrow(1);
|
|
|
|
root_child0.setMargin(Yoga.EDGE_TOP, 10);
|
|
|
|
root_child0.setMargin(Yoga.EDGE_BOTTOM, 10);
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(100);
|
|
|
|
expect(root.getComputedHeight()).toBe(100);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(10);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(100);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(80);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(100);
|
|
|
|
expect(root.getComputedHeight()).toBe(100);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(10);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(100);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(80);
|
2017-02-20 05:31:20 -08:00
|
|
|
} 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
|
|
|
});
|
2022-12-24 02:17:10 -08:00
|
|
|
test("margin_and_stretch_column", () => {
|
2022-12-24 00:35:10 -08:00
|
|
|
const config = Yoga.Config.create();
|
2022-12-24 01:46:20 -08:00
|
|
|
let root;
|
2017-03-28 10:28:53 -07:00
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2022-12-24 01:46:20 -08:00
|
|
|
root = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root.setWidth(100);
|
|
|
|
root.setHeight(100);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child0 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child0.setFlexGrow(1);
|
|
|
|
root_child0.setMargin(Yoga.EDGE_START, 10);
|
|
|
|
root_child0.setMargin(Yoga.EDGE_END, 10);
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(100);
|
|
|
|
expect(root.getComputedHeight()).toBe(100);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(10);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(80);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(100);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(100);
|
|
|
|
expect(root.getComputedHeight()).toBe(100);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(10);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(80);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(100);
|
2017-02-20 05:31:20 -08:00
|
|
|
} 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
|
|
|
});
|
2022-12-24 02:17:10 -08:00
|
|
|
test("margin_with_sibling_row", () => {
|
2022-12-24 00:35:10 -08:00
|
|
|
const config = Yoga.Config.create();
|
2022-12-24 01:46:20 -08:00
|
|
|
let root;
|
2017-03-28 10:28:53 -07:00
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2022-12-24 01:46:20 -08:00
|
|
|
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);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child0 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child0.setFlexGrow(1);
|
|
|
|
root_child0.setMargin(Yoga.EDGE_END, 10);
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const 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);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(100);
|
|
|
|
expect(root.getComputedHeight()).toBe(100);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(45);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(100);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child1.getComputedLeft()).toBe(55);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(45);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(100);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(100);
|
|
|
|
expect(root.getComputedHeight()).toBe(100);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(55);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(45);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(100);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child1.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(45);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(100);
|
2017-02-20 05:31:20 -08:00
|
|
|
} 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
|
|
|
});
|
2022-12-24 02:17:10 -08:00
|
|
|
test("margin_with_sibling_column", () => {
|
2022-12-24 00:35:10 -08:00
|
|
|
const config = Yoga.Config.create();
|
2022-12-24 01:46:20 -08:00
|
|
|
let root;
|
2017-03-28 10:28:53 -07:00
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2022-12-24 01:46:20 -08:00
|
|
|
root = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root.setWidth(100);
|
|
|
|
root.setHeight(100);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child0 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child0.setFlexGrow(1);
|
|
|
|
root_child0.setMargin(Yoga.EDGE_BOTTOM, 10);
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const 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);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(100);
|
|
|
|
expect(root.getComputedHeight()).toBe(100);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(100);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(45);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child1.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(55);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(100);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(45);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(100);
|
|
|
|
expect(root.getComputedHeight()).toBe(100);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(100);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(45);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child1.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(55);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(100);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(45);
|
2017-02-20 05:31:20 -08:00
|
|
|
} 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
|
|
|
});
|
2022-12-24 02:17:10 -08:00
|
|
|
test("margin_auto_bottom", () => {
|
2022-12-24 00:35:10 -08:00
|
|
|
const config = Yoga.Config.create();
|
2022-12-24 01:46:20 -08:00
|
|
|
let root;
|
2017-03-28 10:28:53 -07:00
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2022-12-24 01:46:20 -08:00
|
|
|
root = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root.setAlignItems(Yoga.ALIGN_CENTER);
|
|
|
|
root.setWidth(200);
|
|
|
|
root.setHeight(200);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child0 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child0.setMargin(Yoga.EDGE_BOTTOM, "auto");
|
|
|
|
root_child0.setWidth(50);
|
|
|
|
root_child0.setHeight(50);
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const 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);
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
|
|
expect(root.getComputedHeight()).toBe(200);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(75);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child1.getComputedLeft()).toBe(75);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(150);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
|
|
expect(root.getComputedHeight()).toBe(200);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(75);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child1.getComputedLeft()).toBe(75);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(150);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
} 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-14 14:26:09 -08:00
|
|
|
});
|
2022-12-24 02:17:10 -08:00
|
|
|
test("margin_auto_top", () => {
|
2022-12-24 00:35:10 -08:00
|
|
|
const config = Yoga.Config.create();
|
2022-12-24 01:46:20 -08:00
|
|
|
let root;
|
2017-03-28 10:28:53 -07:00
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2022-12-24 01:46:20 -08:00
|
|
|
root = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root.setAlignItems(Yoga.ALIGN_CENTER);
|
|
|
|
root.setWidth(200);
|
|
|
|
root.setHeight(200);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child0 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child0.setMargin(Yoga.EDGE_TOP, "auto");
|
|
|
|
root_child0.setWidth(50);
|
|
|
|
root_child0.setHeight(50);
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const 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);
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
|
|
expect(root.getComputedHeight()).toBe(200);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(75);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(100);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child1.getComputedLeft()).toBe(75);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(150);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
|
|
expect(root.getComputedHeight()).toBe(200);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(75);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(100);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child1.getComputedLeft()).toBe(75);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(150);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
} 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-14 14:26:09 -08:00
|
|
|
});
|
2022-12-24 02:17:10 -08:00
|
|
|
test("margin_auto_bottom_and_top", () => {
|
2022-12-24 00:35:10 -08:00
|
|
|
const config = Yoga.Config.create();
|
2022-12-24 01:46:20 -08:00
|
|
|
let root;
|
2017-03-28 10:28:53 -07:00
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2022-12-24 01:46:20 -08:00
|
|
|
root = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root.setAlignItems(Yoga.ALIGN_CENTER);
|
|
|
|
root.setWidth(200);
|
|
|
|
root.setHeight(200);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child0 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child0.setMargin(Yoga.EDGE_TOP, "auto");
|
|
|
|
root_child0.setMargin(Yoga.EDGE_BOTTOM, "auto");
|
|
|
|
root_child0.setWidth(50);
|
|
|
|
root_child0.setHeight(50);
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const 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);
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
|
|
expect(root.getComputedHeight()).toBe(200);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(75);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(50);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child1.getComputedLeft()).toBe(75);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(150);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
|
|
expect(root.getComputedHeight()).toBe(200);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(75);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(50);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child1.getComputedLeft()).toBe(75);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(150);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
} 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-14 14:26:09 -08:00
|
|
|
});
|
2022-12-24 02:17:10 -08:00
|
|
|
test("margin_auto_bottom_and_top_justify_center", () => {
|
2022-12-24 00:35:10 -08:00
|
|
|
const config = Yoga.Config.create();
|
2022-12-24 01:46:20 -08:00
|
|
|
let root;
|
2017-03-28 10:28:53 -07:00
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2022-12-24 01:46:20 -08:00
|
|
|
root = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root.setJustifyContent(Yoga.JUSTIFY_CENTER);
|
|
|
|
root.setWidth(200);
|
|
|
|
root.setHeight(200);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child0 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child0.setMargin(Yoga.EDGE_TOP, "auto");
|
|
|
|
root_child0.setMargin(Yoga.EDGE_BOTTOM, "auto");
|
|
|
|
root_child0.setWidth(50);
|
|
|
|
root_child0.setHeight(50);
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const 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);
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
|
|
expect(root.getComputedHeight()).toBe(200);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(50);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child1.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(150);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
|
|
expect(root.getComputedHeight()).toBe(200);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(150);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(50);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child1.getComputedLeft()).toBe(150);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(150);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
} 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-14 14:26:09 -08:00
|
|
|
});
|
2022-12-24 02:17:10 -08:00
|
|
|
test("margin_auto_mutiple_children_column", () => {
|
2022-12-24 00:35:10 -08:00
|
|
|
const config = Yoga.Config.create();
|
2022-12-24 01:46:20 -08:00
|
|
|
let root;
|
2017-03-28 10:28:53 -07:00
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2022-12-24 01:46:20 -08:00
|
|
|
root = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root.setAlignItems(Yoga.ALIGN_CENTER);
|
|
|
|
root.setWidth(200);
|
|
|
|
root.setHeight(200);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child0 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child0.setMargin(Yoga.EDGE_TOP, "auto");
|
|
|
|
root_child0.setWidth(50);
|
|
|
|
root_child0.setHeight(50);
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child1 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child1.setMargin(Yoga.EDGE_TOP, "auto");
|
|
|
|
root_child1.setWidth(50);
|
|
|
|
root_child1.setHeight(50);
|
|
|
|
root.insertChild(root_child1, 1);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const 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);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
|
|
expect(root.getComputedHeight()).toBe(200);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(75);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(25);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child1.getComputedLeft()).toBe(75);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(100);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child2.getComputedLeft()).toBe(75);
|
|
|
|
expect(root_child2.getComputedTop()).toBe(150);
|
|
|
|
expect(root_child2.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child2.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(75);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(25);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(50);
|
|
|
|
|
|
|
|
expect(root_child1.getComputedLeft()).toBe(75);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(100);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(50);
|
|
|
|
|
|
|
|
expect(root_child2.getComputedLeft()).toBe(75);
|
|
|
|
expect(root_child2.getComputedTop()).toBe(150);
|
|
|
|
expect(root_child2.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child2.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
} 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-14 14:26:09 -08:00
|
|
|
});
|
2022-12-24 02:17:10 -08:00
|
|
|
test("margin_auto_mutiple_children_row", () => {
|
2022-12-24 00:35:10 -08:00
|
|
|
const config = Yoga.Config.create();
|
2022-12-24 01:46:20 -08:00
|
|
|
let root;
|
2017-03-28 10:28:53 -07:00
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2022-12-24 01:46:20 -08:00
|
|
|
root = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
|
|
|
root.setAlignItems(Yoga.ALIGN_CENTER);
|
|
|
|
root.setWidth(200);
|
|
|
|
root.setHeight(200);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child0 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child0.setMargin(Yoga.EDGE_RIGHT, "auto");
|
|
|
|
root_child0.setWidth(50);
|
|
|
|
root_child0.setHeight(50);
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child1 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child1.setMargin(Yoga.EDGE_RIGHT, "auto");
|
|
|
|
root_child1.setWidth(50);
|
|
|
|
root_child1.setHeight(50);
|
|
|
|
root.insertChild(root_child1, 1);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const 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);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
|
|
expect(root.getComputedHeight()).toBe(200);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(75);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child1.getComputedLeft()).toBe(75);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(75);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child2.getComputedLeft()).toBe(150);
|
|
|
|
expect(root_child2.getComputedTop()).toBe(75);
|
|
|
|
expect(root_child2.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child2.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(125);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(75);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(50);
|
|
|
|
|
|
|
|
expect(root_child1.getComputedLeft()).toBe(50);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(75);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(50);
|
|
|
|
|
|
|
|
expect(root_child2.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child2.getComputedTop()).toBe(75);
|
|
|
|
expect(root_child2.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child2.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
} 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-14 14:26:09 -08:00
|
|
|
});
|
2022-12-24 02:17:10 -08:00
|
|
|
test("margin_auto_left_and_right_column", () => {
|
2022-12-24 00:35:10 -08:00
|
|
|
const config = Yoga.Config.create();
|
2022-12-24 01:46:20 -08:00
|
|
|
let root;
|
2017-03-28 10:28:53 -07:00
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2022-12-24 01:46:20 -08:00
|
|
|
root = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
|
|
|
root.setAlignItems(Yoga.ALIGN_CENTER);
|
|
|
|
root.setWidth(200);
|
|
|
|
root.setHeight(200);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child0 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child0.setMargin(Yoga.EDGE_LEFT, "auto");
|
|
|
|
root_child0.setMargin(Yoga.EDGE_RIGHT, "auto");
|
|
|
|
root_child0.setWidth(50);
|
|
|
|
root_child0.setHeight(50);
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const 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);
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
|
|
expect(root.getComputedHeight()).toBe(200);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(50);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(75);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child1.getComputedLeft()).toBe(150);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(75);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
|
|
expect(root.getComputedHeight()).toBe(200);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(100);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(75);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child1.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(75);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
} 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-14 14:26:09 -08:00
|
|
|
});
|
2022-12-24 02:17:10 -08:00
|
|
|
test("margin_auto_left_and_right", () => {
|
2022-12-24 00:35:10 -08:00
|
|
|
const config = Yoga.Config.create();
|
2022-12-24 01:46:20 -08:00
|
|
|
let root;
|
2017-03-28 10:28:53 -07:00
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2022-12-24 01:46:20 -08:00
|
|
|
root = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root.setWidth(200);
|
|
|
|
root.setHeight(200);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child0 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child0.setMargin(Yoga.EDGE_LEFT, "auto");
|
|
|
|
root_child0.setMargin(Yoga.EDGE_RIGHT, "auto");
|
|
|
|
root_child0.setWidth(50);
|
2017-03-01 09:12:40 -08:00
|
|
|
root_child0.setHeight(50);
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child1 = Yoga.Node.create(config);
|
2017-03-01 09:12:40 -08:00
|
|
|
root_child1.setWidth(50);
|
|
|
|
root_child1.setHeight(50);
|
|
|
|
root.insertChild(root_child1, 1);
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
|
|
expect(root.getComputedHeight()).toBe(200);
|
2017-03-01 09:12:40 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(75);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(50);
|
2017-03-01 09:12:40 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child1.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(50);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(50);
|
2017-03-01 09:12:40 -08:00
|
|
|
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
|
|
expect(root.getComputedHeight()).toBe(200);
|
2017-03-01 09:12:40 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(75);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(50);
|
2017-03-01 09:12:40 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child1.getComputedLeft()).toBe(150);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(50);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(50);
|
2017-03-01 09:12:40 -08:00
|
|
|
} finally {
|
|
|
|
if (typeof root !== "undefined") {
|
|
|
|
root.freeRecursive();
|
|
|
|
}
|
2017-03-28 10:28:53 -07:00
|
|
|
|
|
|
|
config.free();
|
2017-03-01 09:12:40 -08:00
|
|
|
}
|
|
|
|
});
|
2022-12-24 02:17:10 -08:00
|
|
|
test("margin_auto_start_and_end_column", () => {
|
2022-12-24 00:35:10 -08:00
|
|
|
const config = Yoga.Config.create();
|
2022-12-24 01:46:20 -08:00
|
|
|
let root;
|
2017-03-28 10:28:53 -07:00
|
|
|
|
2017-03-01 09:12:40 -08:00
|
|
|
try {
|
2022-12-24 01:46:20 -08:00
|
|
|
root = Yoga.Node.create(config);
|
2017-03-01 09:12:40 -08:00
|
|
|
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
|
|
|
root.setAlignItems(Yoga.ALIGN_CENTER);
|
|
|
|
root.setWidth(200);
|
|
|
|
root.setHeight(200);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child0 = Yoga.Node.create(config);
|
2017-03-01 09:12:40 -08:00
|
|
|
root_child0.setMargin(Yoga.EDGE_START, "auto");
|
|
|
|
root_child0.setMargin(Yoga.EDGE_END, "auto");
|
|
|
|
root_child0.setWidth(50);
|
|
|
|
root_child0.setHeight(50);
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child1 = Yoga.Node.create(config);
|
2017-03-01 09:12:40 -08:00
|
|
|
root_child1.setWidth(50);
|
|
|
|
root_child1.setHeight(50);
|
|
|
|
root.insertChild(root_child1, 1);
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
|
|
expect(root.getComputedHeight()).toBe(200);
|
2017-03-01 09:12:40 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(50);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(75);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(50);
|
2017-03-01 09:12:40 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child1.getComputedLeft()).toBe(150);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(75);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(50);
|
2017-03-01 09:12:40 -08:00
|
|
|
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
|
|
expect(root.getComputedHeight()).toBe(200);
|
2017-03-01 09:12:40 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(100);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(75);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(50);
|
2017-03-01 09:12:40 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child1.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(75);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(50);
|
2017-03-01 09:12:40 -08:00
|
|
|
} finally {
|
|
|
|
if (typeof root !== "undefined") {
|
|
|
|
root.freeRecursive();
|
|
|
|
}
|
2017-03-28 10:28:53 -07:00
|
|
|
|
|
|
|
config.free();
|
2017-03-01 09:12:40 -08:00
|
|
|
}
|
|
|
|
});
|
2022-12-24 02:17:10 -08:00
|
|
|
test("margin_auto_start_and_end", () => {
|
2022-12-24 00:35:10 -08:00
|
|
|
const config = Yoga.Config.create();
|
2022-12-24 01:46:20 -08:00
|
|
|
let root;
|
2017-03-28 10:28:53 -07:00
|
|
|
|
2017-03-01 09:12:40 -08:00
|
|
|
try {
|
2022-12-24 01:46:20 -08:00
|
|
|
root = Yoga.Node.create(config);
|
2017-03-01 09:12:40 -08:00
|
|
|
root.setWidth(200);
|
|
|
|
root.setHeight(200);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child0 = Yoga.Node.create(config);
|
2017-03-01 09:12:40 -08:00
|
|
|
root_child0.setMargin(Yoga.EDGE_START, "auto");
|
|
|
|
root_child0.setMargin(Yoga.EDGE_END, "auto");
|
|
|
|
root_child0.setWidth(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child0.setHeight(50);
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const 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);
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
|
|
expect(root.getComputedHeight()).toBe(200);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(75);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child1.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(50);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
|
|
expect(root.getComputedHeight()).toBe(200);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(75);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child1.getComputedLeft()).toBe(150);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(50);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
} 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-14 14:26:09 -08:00
|
|
|
});
|
2022-12-24 02:17:10 -08:00
|
|
|
test("margin_auto_left_and_right_column_and_center", () => {
|
2022-12-24 00:35:10 -08:00
|
|
|
const config = Yoga.Config.create();
|
2022-12-24 01:46:20 -08:00
|
|
|
let root;
|
2017-03-28 10:28:53 -07:00
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2022-12-24 01:46:20 -08:00
|
|
|
root = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root.setAlignItems(Yoga.ALIGN_CENTER);
|
|
|
|
root.setWidth(200);
|
|
|
|
root.setHeight(200);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child0 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child0.setMargin(Yoga.EDGE_LEFT, "auto");
|
|
|
|
root_child0.setMargin(Yoga.EDGE_RIGHT, "auto");
|
|
|
|
root_child0.setWidth(50);
|
|
|
|
root_child0.setHeight(50);
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const 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);
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
|
|
expect(root.getComputedHeight()).toBe(200);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(75);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child1.getComputedLeft()).toBe(75);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(50);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
|
|
expect(root.getComputedHeight()).toBe(200);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(75);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child1.getComputedLeft()).toBe(75);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(50);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
} 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-14 14:26:09 -08:00
|
|
|
});
|
2022-12-24 02:17:10 -08:00
|
|
|
test("margin_auto_left", () => {
|
2022-12-24 00:35:10 -08:00
|
|
|
const config = Yoga.Config.create();
|
2022-12-24 01:46:20 -08:00
|
|
|
let root;
|
2017-03-28 10:28:53 -07:00
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2022-12-24 01:46:20 -08:00
|
|
|
root = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root.setAlignItems(Yoga.ALIGN_CENTER);
|
|
|
|
root.setWidth(200);
|
|
|
|
root.setHeight(200);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child0 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child0.setMargin(Yoga.EDGE_LEFT, "auto");
|
|
|
|
root_child0.setWidth(50);
|
|
|
|
root_child0.setHeight(50);
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const 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);
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
|
|
expect(root.getComputedHeight()).toBe(200);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(150);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child1.getComputedLeft()).toBe(75);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(50);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
|
|
expect(root.getComputedHeight()).toBe(200);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(150);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child1.getComputedLeft()).toBe(75);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(50);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
} 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-14 14:26:09 -08:00
|
|
|
});
|
2022-12-24 02:17:10 -08:00
|
|
|
test("margin_auto_right", () => {
|
2022-12-24 00:35:10 -08:00
|
|
|
const config = Yoga.Config.create();
|
2022-12-24 01:46:20 -08:00
|
|
|
let root;
|
2017-03-28 10:28:53 -07:00
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2022-12-24 01:46:20 -08:00
|
|
|
root = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root.setAlignItems(Yoga.ALIGN_CENTER);
|
|
|
|
root.setWidth(200);
|
|
|
|
root.setHeight(200);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child0 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child0.setMargin(Yoga.EDGE_RIGHT, "auto");
|
|
|
|
root_child0.setWidth(50);
|
|
|
|
root_child0.setHeight(50);
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const 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);
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
|
|
expect(root.getComputedHeight()).toBe(200);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child1.getComputedLeft()).toBe(75);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(50);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
|
|
expect(root.getComputedHeight()).toBe(200);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child1.getComputedLeft()).toBe(75);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(50);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
} 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-14 14:26:09 -08:00
|
|
|
});
|
2022-12-24 02:17:10 -08:00
|
|
|
test("margin_auto_left_and_right_stretch", () => {
|
2022-12-24 00:35:10 -08:00
|
|
|
const config = Yoga.Config.create();
|
2022-12-24 01:46:20 -08:00
|
|
|
let root;
|
2017-03-28 10:28:53 -07:00
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2022-12-24 01:46:20 -08:00
|
|
|
root = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
|
|
|
root.setWidth(200);
|
|
|
|
root.setHeight(200);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child0 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child0.setMargin(Yoga.EDGE_LEFT, "auto");
|
|
|
|
root_child0.setMargin(Yoga.EDGE_RIGHT, "auto");
|
|
|
|
root_child0.setWidth(50);
|
|
|
|
root_child0.setHeight(50);
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const 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);
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
|
|
expect(root.getComputedHeight()).toBe(200);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(50);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child1.getComputedLeft()).toBe(150);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
|
|
expect(root.getComputedHeight()).toBe(200);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(100);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child1.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
} 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-14 14:26:09 -08:00
|
|
|
});
|
2022-12-24 02:17:10 -08:00
|
|
|
test("margin_auto_top_and_bottom_stretch", () => {
|
2022-12-24 00:35:10 -08:00
|
|
|
const config = Yoga.Config.create();
|
2022-12-24 01:46:20 -08:00
|
|
|
let root;
|
2017-03-28 10:28:53 -07:00
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2022-12-24 01:46:20 -08:00
|
|
|
root = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root.setWidth(200);
|
|
|
|
root.setHeight(200);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child0 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child0.setMargin(Yoga.EDGE_TOP, "auto");
|
|
|
|
root_child0.setMargin(Yoga.EDGE_BOTTOM, "auto");
|
|
|
|
root_child0.setWidth(50);
|
|
|
|
root_child0.setHeight(50);
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const 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);
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
|
|
expect(root.getComputedHeight()).toBe(200);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(50);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child1.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(150);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
|
|
expect(root.getComputedHeight()).toBe(200);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(150);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(50);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child1.getComputedLeft()).toBe(150);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(150);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
} 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-14 14:26:09 -08:00
|
|
|
});
|
2022-12-24 02:17:10 -08:00
|
|
|
test("margin_should_not_be_part_of_max_height", () => {
|
2022-12-24 00:35:10 -08:00
|
|
|
const config = Yoga.Config.create();
|
2022-12-24 01:46:20 -08:00
|
|
|
let root;
|
2017-03-28 10:28:53 -07:00
|
|
|
|
2017-03-09 03:48:33 -08:00
|
|
|
try {
|
2022-12-24 01:46:20 -08:00
|
|
|
root = Yoga.Node.create(config);
|
2017-03-09 03:48:33 -08:00
|
|
|
root.setWidth(250);
|
|
|
|
root.setHeight(250);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child0 = Yoga.Node.create(config);
|
2017-03-09 03:48:33 -08:00
|
|
|
root_child0.setMargin(Yoga.EDGE_TOP, 20);
|
|
|
|
root_child0.setWidth(100);
|
|
|
|
root_child0.setHeight(100);
|
|
|
|
root_child0.setMaxHeight(100);
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(250);
|
|
|
|
expect(root.getComputedHeight()).toBe(250);
|
2017-03-09 03:48:33 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(20);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(100);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(100);
|
2017-03-09 03:48:33 -08:00
|
|
|
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(250);
|
|
|
|
expect(root.getComputedHeight()).toBe(250);
|
2017-03-09 03:48:33 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(150);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(20);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(100);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(100);
|
2017-03-09 03:48:33 -08:00
|
|
|
} finally {
|
|
|
|
if (typeof root !== "undefined") {
|
|
|
|
root.freeRecursive();
|
|
|
|
}
|
2017-03-28 10:28:53 -07:00
|
|
|
|
|
|
|
config.free();
|
2017-03-09 03:48:33 -08:00
|
|
|
}
|
|
|
|
});
|
2022-12-24 02:17:10 -08:00
|
|
|
test("margin_should_not_be_part_of_max_width", () => {
|
2022-12-24 00:35:10 -08:00
|
|
|
const config = Yoga.Config.create();
|
2022-12-24 01:46:20 -08:00
|
|
|
let root;
|
2017-03-28 10:28:53 -07:00
|
|
|
|
2017-03-09 03:48:33 -08:00
|
|
|
try {
|
2022-12-24 01:46:20 -08:00
|
|
|
root = Yoga.Node.create(config);
|
2017-03-09 03:48:33 -08:00
|
|
|
root.setWidth(250);
|
|
|
|
root.setHeight(250);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child0 = Yoga.Node.create(config);
|
2017-03-09 03:48:33 -08:00
|
|
|
root_child0.setMargin(Yoga.EDGE_LEFT, 20);
|
|
|
|
root_child0.setWidth(100);
|
|
|
|
root_child0.setMaxWidth(100);
|
|
|
|
root_child0.setHeight(100);
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(250);
|
|
|
|
expect(root.getComputedHeight()).toBe(250);
|
2017-03-09 03:48:33 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(20);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(100);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(100);
|
2017-03-09 03:48:33 -08:00
|
|
|
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(250);
|
|
|
|
expect(root.getComputedHeight()).toBe(250);
|
2017-03-09 03:48:33 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(150);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(100);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(100);
|
2017-03-09 03:48:33 -08:00
|
|
|
} finally {
|
|
|
|
if (typeof root !== "undefined") {
|
|
|
|
root.freeRecursive();
|
|
|
|
}
|
2017-03-28 10:28:53 -07:00
|
|
|
|
|
|
|
config.free();
|
2017-03-09 03:48:33 -08:00
|
|
|
}
|
|
|
|
});
|
2022-12-24 02:17:10 -08:00
|
|
|
test("margin_auto_left_right_child_bigger_than_parent", () => {
|
2022-12-24 00:35:10 -08:00
|
|
|
const config = Yoga.Config.create();
|
2022-12-24 01:46:20 -08:00
|
|
|
let root;
|
2017-03-28 10:28:53 -07:00
|
|
|
|
2017-03-15 05:20:38 -07:00
|
|
|
try {
|
2022-12-24 01:46:20 -08:00
|
|
|
root = Yoga.Node.create(config);
|
2017-03-15 05:20:38 -07:00
|
|
|
root.setJustifyContent(Yoga.JUSTIFY_CENTER);
|
|
|
|
root.setWidth(52);
|
|
|
|
root.setHeight(52);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child0 = Yoga.Node.create(config);
|
2017-03-15 05:20:38 -07:00
|
|
|
root_child0.setMargin(Yoga.EDGE_LEFT, "auto");
|
|
|
|
root_child0.setMargin(Yoga.EDGE_RIGHT, "auto");
|
|
|
|
root_child0.setWidth(72);
|
|
|
|
root_child0.setHeight(72);
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(52);
|
|
|
|
expect(root.getComputedHeight()).toBe(52);
|
2017-03-15 05:20:38 -07:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(-10);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(72);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(72);
|
2017-03-15 05:20:38 -07:00
|
|
|
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(52);
|
|
|
|
expect(root.getComputedHeight()).toBe(52);
|
2017-03-15 05:20:38 -07:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(-20);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(-10);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(72);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(72);
|
2017-03-15 05:20:38 -07:00
|
|
|
} finally {
|
|
|
|
if (typeof root !== "undefined") {
|
|
|
|
root.freeRecursive();
|
|
|
|
}
|
2017-03-28 10:28:53 -07:00
|
|
|
|
|
|
|
config.free();
|
2017-03-15 05:20:38 -07:00
|
|
|
}
|
|
|
|
});
|
2022-12-24 02:17:10 -08:00
|
|
|
test("margin_auto_left_child_bigger_than_parent", () => {
|
2022-12-24 00:35:10 -08:00
|
|
|
const config = Yoga.Config.create();
|
2022-12-24 01:46:20 -08:00
|
|
|
let root;
|
2017-03-28 10:28:53 -07:00
|
|
|
|
2017-03-15 05:20:38 -07:00
|
|
|
try {
|
2022-12-24 01:46:20 -08:00
|
|
|
root = Yoga.Node.create(config);
|
2017-03-15 05:20:38 -07:00
|
|
|
root.setJustifyContent(Yoga.JUSTIFY_CENTER);
|
|
|
|
root.setWidth(52);
|
|
|
|
root.setHeight(52);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child0 = Yoga.Node.create(config);
|
2017-03-15 05:20:38 -07:00
|
|
|
root_child0.setMargin(Yoga.EDGE_LEFT, "auto");
|
|
|
|
root_child0.setWidth(72);
|
|
|
|
root_child0.setHeight(72);
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(52);
|
|
|
|
expect(root.getComputedHeight()).toBe(52);
|
2017-03-15 05:20:38 -07:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(-10);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(72);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(72);
|
2017-03-15 05:20:38 -07:00
|
|
|
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(52);
|
|
|
|
expect(root.getComputedHeight()).toBe(52);
|
2017-03-15 05:20:38 -07:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(-20);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(-10);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(72);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(72);
|
2017-03-15 05:20:38 -07:00
|
|
|
} finally {
|
|
|
|
if (typeof root !== "undefined") {
|
|
|
|
root.freeRecursive();
|
|
|
|
}
|
2017-03-28 10:28:53 -07:00
|
|
|
|
|
|
|
config.free();
|
2017-03-15 05:20:38 -07:00
|
|
|
}
|
|
|
|
});
|
2022-12-24 02:17:10 -08:00
|
|
|
test("margin_fix_left_auto_right_child_bigger_than_parent", () => {
|
2022-12-24 00:35:10 -08:00
|
|
|
const config = Yoga.Config.create();
|
2022-12-24 01:46:20 -08:00
|
|
|
let root;
|
2017-03-28 10:28:53 -07:00
|
|
|
|
2017-03-15 05:20:38 -07:00
|
|
|
try {
|
2022-12-24 01:46:20 -08:00
|
|
|
root = Yoga.Node.create(config);
|
2017-03-15 05:20:38 -07:00
|
|
|
root.setJustifyContent(Yoga.JUSTIFY_CENTER);
|
|
|
|
root.setWidth(52);
|
|
|
|
root.setHeight(52);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child0 = Yoga.Node.create(config);
|
2017-03-15 05:20:38 -07:00
|
|
|
root_child0.setMargin(Yoga.EDGE_LEFT, 10);
|
|
|
|
root_child0.setMargin(Yoga.EDGE_RIGHT, "auto");
|
|
|
|
root_child0.setWidth(72);
|
|
|
|
root_child0.setHeight(72);
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(52);
|
|
|
|
expect(root.getComputedHeight()).toBe(52);
|
2017-03-15 05:20:38 -07:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(10);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(-10);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(72);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(72);
|
2017-03-15 05:20:38 -07:00
|
|
|
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(52);
|
|
|
|
expect(root.getComputedHeight()).toBe(52);
|
2017-03-15 05:20:38 -07:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(-20);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(-10);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(72);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(72);
|
2017-03-15 05:20:38 -07:00
|
|
|
} finally {
|
|
|
|
if (typeof root !== "undefined") {
|
|
|
|
root.freeRecursive();
|
|
|
|
}
|
2017-03-28 10:28:53 -07:00
|
|
|
|
|
|
|
config.free();
|
2017-03-15 05:20:38 -07:00
|
|
|
}
|
|
|
|
});
|
2022-12-24 02:17:10 -08:00
|
|
|
test("margin_auto_left_fix_right_child_bigger_than_parent", () => {
|
2022-12-24 00:35:10 -08:00
|
|
|
const config = Yoga.Config.create();
|
2022-12-24 01:46:20 -08:00
|
|
|
let root;
|
2017-03-28 10:28:53 -07:00
|
|
|
|
2017-03-15 05:20:38 -07:00
|
|
|
try {
|
2022-12-24 01:46:20 -08:00
|
|
|
root = Yoga.Node.create(config);
|
2017-03-15 05:20:38 -07:00
|
|
|
root.setJustifyContent(Yoga.JUSTIFY_CENTER);
|
|
|
|
root.setWidth(52);
|
|
|
|
root.setHeight(52);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child0 = Yoga.Node.create(config);
|
2017-03-15 05:20:38 -07:00
|
|
|
root_child0.setMargin(Yoga.EDGE_LEFT, "auto");
|
|
|
|
root_child0.setMargin(Yoga.EDGE_RIGHT, 10);
|
|
|
|
root_child0.setWidth(72);
|
|
|
|
root_child0.setHeight(72);
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(52);
|
|
|
|
expect(root.getComputedHeight()).toBe(52);
|
2017-03-15 05:20:38 -07:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(-10);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(72);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(72);
|
2017-03-15 05:20:38 -07:00
|
|
|
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(52);
|
|
|
|
expect(root.getComputedHeight()).toBe(52);
|
2017-03-15 05:20:38 -07:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(-30);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(-10);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(72);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(72);
|
2017-03-15 05:20:38 -07:00
|
|
|
} finally {
|
|
|
|
if (typeof root !== "undefined") {
|
|
|
|
root.freeRecursive();
|
|
|
|
}
|
2017-03-28 10:28:53 -07:00
|
|
|
|
|
|
|
config.free();
|
2017-03-15 05:20:38 -07:00
|
|
|
}
|
|
|
|
});
|
2022-12-24 02:17:10 -08:00
|
|
|
test("margin_auto_top_stretching_child", () => {
|
2022-12-24 00:35:10 -08:00
|
|
|
const config = Yoga.Config.create();
|
2022-12-24 01:46:20 -08:00
|
|
|
let root;
|
2017-11-27 05:29:15 -08:00
|
|
|
|
|
|
|
try {
|
2022-12-24 01:46:20 -08:00
|
|
|
root = Yoga.Node.create(config);
|
2017-11-27 05:29:15 -08:00
|
|
|
root.setAlignItems(Yoga.ALIGN_CENTER);
|
|
|
|
root.setWidth(200);
|
|
|
|
root.setHeight(200);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child0 = Yoga.Node.create(config);
|
2017-11-27 05:29:15 -08:00
|
|
|
root_child0.setFlexGrow(1);
|
|
|
|
root_child0.setFlexShrink(1);
|
|
|
|
root_child0.setFlexBasis("0%");
|
|
|
|
root_child0.setMargin(Yoga.EDGE_TOP, "auto");
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child1 = Yoga.Node.create(config);
|
2017-11-27 05:29:15 -08:00
|
|
|
root_child1.setWidth(50);
|
|
|
|
root_child1.setHeight(50);
|
|
|
|
root.insertChild(root_child1, 1);
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
|
|
expect(root.getComputedHeight()).toBe(200);
|
2017-11-27 05:29:15 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(100);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(0);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(150);
|
2017-11-27 05:29:15 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child1.getComputedLeft()).toBe(75);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(150);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(50);
|
2017-11-27 05:29:15 -08:00
|
|
|
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
|
|
expect(root.getComputedHeight()).toBe(200);
|
2017-11-27 05:29:15 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(100);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(0);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(150);
|
2017-11-27 05:29:15 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child1.getComputedLeft()).toBe(75);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(150);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(50);
|
2017-11-27 05:29:15 -08:00
|
|
|
} finally {
|
|
|
|
if (typeof root !== "undefined") {
|
|
|
|
root.freeRecursive();
|
|
|
|
}
|
|
|
|
|
|
|
|
config.free();
|
|
|
|
}
|
|
|
|
});
|
2022-12-24 02:17:10 -08:00
|
|
|
test("margin_auto_left_stretching_child", () => {
|
2022-12-24 00:35:10 -08:00
|
|
|
const config = Yoga.Config.create();
|
2022-12-24 01:46:20 -08:00
|
|
|
let root;
|
2017-11-27 05:29:15 -08:00
|
|
|
|
|
|
|
try {
|
2022-12-24 01:46:20 -08:00
|
|
|
root = Yoga.Node.create(config);
|
2017-11-27 05:29:15 -08:00
|
|
|
root.setAlignItems(Yoga.ALIGN_CENTER);
|
|
|
|
root.setWidth(200);
|
|
|
|
root.setHeight(200);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child0 = Yoga.Node.create(config);
|
2017-11-27 05:29:15 -08:00
|
|
|
root_child0.setFlexGrow(1);
|
|
|
|
root_child0.setFlexShrink(1);
|
|
|
|
root_child0.setFlexBasis("0%");
|
|
|
|
root_child0.setMargin(Yoga.EDGE_LEFT, "auto");
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child1 = Yoga.Node.create(config);
|
2017-11-27 05:29:15 -08:00
|
|
|
root_child1.setWidth(50);
|
|
|
|
root_child1.setHeight(50);
|
|
|
|
root.insertChild(root_child1, 1);
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
|
|
expect(root.getComputedHeight()).toBe(200);
|
2017-11-27 05:29:15 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(200);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(0);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(150);
|
2017-11-27 05:29:15 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child1.getComputedLeft()).toBe(75);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(150);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(50);
|
2017-11-27 05:29:15 -08:00
|
|
|
|
|
|
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
|
|
expect(root.getComputedTop()).toBe(0);
|
|
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
|
|
expect(root.getComputedHeight()).toBe(200);
|
2017-11-27 05:29:15 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0.getComputedLeft()).toBe(200);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(0);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(150);
|
2017-11-27 05:29:15 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child1.getComputedLeft()).toBe(75);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(150);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(50);
|
2017-11-27 05:29:15 -08:00
|
|
|
} finally {
|
|
|
|
if (typeof root !== "undefined") {
|
|
|
|
root.freeRecursive();
|
|
|
|
}
|
|
|
|
|
|
|
|
config.free();
|
|
|
|
}
|
|
|
|
});
|