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/YGAlignContentTest.html
|
2017-01-02 02:22:45 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
test("align_content_flex_start", function () {
|
|
|
|
const config = Yoga.Config.create();
|
2017-03-28 10:28:53 -07:00
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2022-12-24 00:35:10 -08:00
|
|
|
const root = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
|
|
|
root.setFlexWrap(Yoga.WRAP_WRAP);
|
|
|
|
root.setWidth(130);
|
|
|
|
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.setWidth(50);
|
|
|
|
root_child0.setHeight(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.setWidth(50);
|
|
|
|
root_child1.setHeight(10);
|
|
|
|
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(10);
|
|
|
|
root.insertChild(root_child2, 2);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child3 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child3.setWidth(50);
|
|
|
|
root_child3.setHeight(10);
|
|
|
|
root.insertChild(root_child3, 3);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child4 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child4.setWidth(50);
|
|
|
|
root_child4.setHeight(10);
|
|
|
|
root.insertChild(root_child4, 4);
|
|
|
|
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(130);
|
|
|
|
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(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(10);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child1.getComputedLeft()).toBe(50);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(10);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child2.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child2.getComputedTop()).toBe(10);
|
|
|
|
expect(root_child2.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child2.getComputedHeight()).toBe(10);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child3.getComputedLeft()).toBe(50);
|
|
|
|
expect(root_child3.getComputedTop()).toBe(10);
|
|
|
|
expect(root_child3.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child3.getComputedHeight()).toBe(10);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child4.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child4.getComputedTop()).toBe(20);
|
|
|
|
expect(root_child4.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child4.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(130);
|
|
|
|
expect(root.getComputedHeight()).toBe(100);
|
|
|
|
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(80);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(10);
|
|
|
|
|
|
|
|
expect(root_child1.getComputedLeft()).toBe(30);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(10);
|
|
|
|
|
|
|
|
expect(root_child2.getComputedLeft()).toBe(80);
|
|
|
|
expect(root_child2.getComputedTop()).toBe(10);
|
|
|
|
expect(root_child2.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child2.getComputedHeight()).toBe(10);
|
|
|
|
|
|
|
|
expect(root_child3.getComputedLeft()).toBe(30);
|
|
|
|
expect(root_child3.getComputedTop()).toBe(10);
|
|
|
|
expect(root_child3.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child3.getComputedHeight()).toBe(10);
|
|
|
|
|
|
|
|
expect(root_child4.getComputedLeft()).toBe(80);
|
|
|
|
expect(root_child4.getComputedTop()).toBe(20);
|
|
|
|
expect(root_child4.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child4.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 00:35:10 -08:00
|
|
|
test("align_content_flex_start_without_height_on_children", function () {
|
|
|
|
const config = Yoga.Config.create();
|
2017-03-28 10:28:53 -07:00
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2022-12-24 00:35:10 -08:00
|
|
|
const root = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root.setFlexWrap(Yoga.WRAP_WRAP);
|
|
|
|
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.setWidth(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(10);
|
|
|
|
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.insertChild(root_child2, 2);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child3 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child3.setWidth(50);
|
|
|
|
root_child3.setHeight(10);
|
|
|
|
root.insertChild(root_child3, 3);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child4 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child4.setWidth(50);
|
|
|
|
root.insertChild(root_child4, 4);
|
|
|
|
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(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(0);
|
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(10);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child2.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child2.getComputedTop()).toBe(10);
|
|
|
|
expect(root_child2.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child2.getComputedHeight()).toBe(0);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child3.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child3.getComputedTop()).toBe(10);
|
|
|
|
expect(root_child3.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child3.getComputedHeight()).toBe(10);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child4.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child4.getComputedTop()).toBe(20);
|
|
|
|
expect(root_child4.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child4.getComputedHeight()).toBe(0);
|
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);
|
|
|
|
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(50);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(0);
|
|
|
|
|
|
|
|
expect(root_child1.getComputedLeft()).toBe(50);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(10);
|
|
|
|
|
|
|
|
expect(root_child2.getComputedLeft()).toBe(50);
|
|
|
|
expect(root_child2.getComputedTop()).toBe(10);
|
|
|
|
expect(root_child2.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child2.getComputedHeight()).toBe(0);
|
|
|
|
|
|
|
|
expect(root_child3.getComputedLeft()).toBe(50);
|
|
|
|
expect(root_child3.getComputedTop()).toBe(10);
|
|
|
|
expect(root_child3.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child3.getComputedHeight()).toBe(10);
|
|
|
|
|
|
|
|
expect(root_child4.getComputedLeft()).toBe(50);
|
|
|
|
expect(root_child4.getComputedTop()).toBe(20);
|
|
|
|
expect(root_child4.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child4.getComputedHeight()).toBe(0);
|
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 09:16:59 -08:00
|
|
|
});
|
2022-12-24 00:35:10 -08:00
|
|
|
test("align_content_flex_start_with_flex", function () {
|
|
|
|
const config = Yoga.Config.create();
|
2017-03-28 10:28:53 -07:00
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2022-12-24 00:35:10 -08:00
|
|
|
const root = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root.setFlexWrap(Yoga.WRAP_WRAP);
|
|
|
|
root.setWidth(100);
|
|
|
|
root.setHeight(120);
|
|
|
|
|
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.setFlexBasis("0%");
|
|
|
|
root_child0.setWidth(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.setFlexGrow(1);
|
|
|
|
root_child1.setFlexBasis("0%");
|
|
|
|
root_child1.setWidth(50);
|
|
|
|
root_child1.setHeight(10);
|
|
|
|
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.insertChild(root_child2, 2);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child3 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child3.setFlexGrow(1);
|
|
|
|
root_child3.setFlexShrink(1);
|
|
|
|
root_child3.setFlexBasis("0%");
|
|
|
|
root_child3.setWidth(50);
|
|
|
|
root.insertChild(root_child3, 3);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child4 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child4.setWidth(50);
|
|
|
|
root.insertChild(root_child4, 4);
|
|
|
|
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(120);
|
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(40);
|
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(40);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(40);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child2.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child2.getComputedTop()).toBe(80);
|
|
|
|
expect(root_child2.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child2.getComputedHeight()).toBe(0);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child3.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child3.getComputedTop()).toBe(80);
|
|
|
|
expect(root_child3.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child3.getComputedHeight()).toBe(40);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child4.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child4.getComputedTop()).toBe(120);
|
|
|
|
expect(root_child4.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child4.getComputedHeight()).toBe(0);
|
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(120);
|
|
|
|
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(50);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(40);
|
|
|
|
|
|
|
|
expect(root_child1.getComputedLeft()).toBe(50);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(40);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(40);
|
|
|
|
|
|
|
|
expect(root_child2.getComputedLeft()).toBe(50);
|
|
|
|
expect(root_child2.getComputedTop()).toBe(80);
|
|
|
|
expect(root_child2.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child2.getComputedHeight()).toBe(0);
|
|
|
|
|
|
|
|
expect(root_child3.getComputedLeft()).toBe(50);
|
|
|
|
expect(root_child3.getComputedTop()).toBe(80);
|
|
|
|
expect(root_child3.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child3.getComputedHeight()).toBe(40);
|
|
|
|
|
|
|
|
expect(root_child4.getComputedLeft()).toBe(50);
|
|
|
|
expect(root_child4.getComputedTop()).toBe(120);
|
|
|
|
expect(root_child4.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child4.getComputedHeight()).toBe(0);
|
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 00:35:10 -08:00
|
|
|
test("align_content_flex_end", function () {
|
|
|
|
const config = Yoga.Config.create();
|
2017-03-28 10:28:53 -07:00
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2022-12-24 00:35:10 -08:00
|
|
|
const root = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root.setAlignContent(Yoga.ALIGN_FLEX_END);
|
|
|
|
root.setFlexWrap(Yoga.WRAP_WRAP);
|
|
|
|
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.setWidth(50);
|
|
|
|
root_child0.setHeight(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.setWidth(50);
|
|
|
|
root_child1.setHeight(10);
|
|
|
|
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(10);
|
|
|
|
root.insertChild(root_child2, 2);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child3 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child3.setWidth(50);
|
|
|
|
root_child3.setHeight(10);
|
|
|
|
root.insertChild(root_child3, 3);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child4 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child4.setWidth(50);
|
|
|
|
root_child4.setHeight(10);
|
|
|
|
root.insertChild(root_child4, 4);
|
|
|
|
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(50);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(10);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child1.getComputedLeft()).toBe(50);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(10);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(10);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child2.getComputedLeft()).toBe(50);
|
|
|
|
expect(root_child2.getComputedTop()).toBe(20);
|
|
|
|
expect(root_child2.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child2.getComputedHeight()).toBe(10);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child3.getComputedLeft()).toBe(50);
|
|
|
|
expect(root_child3.getComputedTop()).toBe(30);
|
|
|
|
expect(root_child3.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child3.getComputedHeight()).toBe(10);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child4.getComputedLeft()).toBe(50);
|
|
|
|
expect(root_child4.getComputedTop()).toBe(40);
|
|
|
|
expect(root_child4.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child4.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);
|
|
|
|
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(10);
|
|
|
|
|
|
|
|
expect(root_child1.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(10);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(10);
|
|
|
|
|
|
|
|
expect(root_child2.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child2.getComputedTop()).toBe(20);
|
|
|
|
expect(root_child2.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child2.getComputedHeight()).toBe(10);
|
|
|
|
|
|
|
|
expect(root_child3.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child3.getComputedTop()).toBe(30);
|
|
|
|
expect(root_child3.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child3.getComputedHeight()).toBe(10);
|
|
|
|
|
|
|
|
expect(root_child4.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child4.getComputedTop()).toBe(40);
|
|
|
|
expect(root_child4.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child4.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 00:35:10 -08:00
|
|
|
test("align_content_stretch", function () {
|
|
|
|
const config = Yoga.Config.create();
|
2017-03-28 10:28:53 -07:00
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2022-12-24 00:35:10 -08:00
|
|
|
const root = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root.setAlignContent(Yoga.ALIGN_STRETCH);
|
|
|
|
root.setFlexWrap(Yoga.WRAP_WRAP);
|
|
|
|
root.setWidth(150);
|
|
|
|
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.setWidth(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.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.insertChild(root_child2, 2);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child3 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child3.setWidth(50);
|
|
|
|
root.insertChild(root_child3, 3);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child4 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child4.setWidth(50);
|
|
|
|
root.insertChild(root_child4, 4);
|
|
|
|
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(150);
|
|
|
|
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(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(0);
|
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(0);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child2.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child2.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child2.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child2.getComputedHeight()).toBe(0);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child3.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child3.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child3.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child3.getComputedHeight()).toBe(0);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child4.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child4.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child4.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child4.getComputedHeight()).toBe(0);
|
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(150);
|
|
|
|
expect(root.getComputedHeight()).toBe(100);
|
|
|
|
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(100);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(0);
|
|
|
|
|
|
|
|
expect(root_child1.getComputedLeft()).toBe(100);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(0);
|
|
|
|
|
|
|
|
expect(root_child2.getComputedLeft()).toBe(100);
|
|
|
|
expect(root_child2.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child2.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child2.getComputedHeight()).toBe(0);
|
|
|
|
|
|
|
|
expect(root_child3.getComputedLeft()).toBe(100);
|
|
|
|
expect(root_child3.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child3.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child3.getComputedHeight()).toBe(0);
|
|
|
|
|
|
|
|
expect(root_child4.getComputedLeft()).toBe(100);
|
|
|
|
expect(root_child4.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child4.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child4.getComputedHeight()).toBe(0);
|
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 00:35:10 -08:00
|
|
|
test("align_content_spacebetween", function () {
|
|
|
|
const config = Yoga.Config.create();
|
2017-03-28 10:28:53 -07:00
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2022-12-24 00:35:10 -08:00
|
|
|
const root = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
|
|
|
root.setAlignContent(Yoga.ALIGN_SPACE_BETWEEN);
|
|
|
|
root.setFlexWrap(Yoga.WRAP_WRAP);
|
|
|
|
root.setWidth(130);
|
|
|
|
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.setWidth(50);
|
|
|
|
root_child0.setHeight(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.setWidth(50);
|
|
|
|
root_child1.setHeight(10);
|
|
|
|
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(10);
|
|
|
|
root.insertChild(root_child2, 2);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child3 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child3.setWidth(50);
|
|
|
|
root_child3.setHeight(10);
|
|
|
|
root.insertChild(root_child3, 3);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child4 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child4.setWidth(50);
|
|
|
|
root_child4.setHeight(10);
|
|
|
|
root.insertChild(root_child4, 4);
|
|
|
|
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(130);
|
|
|
|
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(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(10);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child1.getComputedLeft()).toBe(50);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(10);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child2.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child2.getComputedTop()).toBe(45);
|
|
|
|
expect(root_child2.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child2.getComputedHeight()).toBe(10);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child3.getComputedLeft()).toBe(50);
|
|
|
|
expect(root_child3.getComputedTop()).toBe(45);
|
|
|
|
expect(root_child3.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child3.getComputedHeight()).toBe(10);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child4.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child4.getComputedTop()).toBe(90);
|
|
|
|
expect(root_child4.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child4.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(130);
|
|
|
|
expect(root.getComputedHeight()).toBe(100);
|
|
|
|
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(80);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(10);
|
|
|
|
|
|
|
|
expect(root_child1.getComputedLeft()).toBe(30);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(10);
|
|
|
|
|
|
|
|
expect(root_child2.getComputedLeft()).toBe(80);
|
|
|
|
expect(root_child2.getComputedTop()).toBe(45);
|
|
|
|
expect(root_child2.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child2.getComputedHeight()).toBe(10);
|
|
|
|
|
|
|
|
expect(root_child3.getComputedLeft()).toBe(30);
|
|
|
|
expect(root_child3.getComputedTop()).toBe(45);
|
|
|
|
expect(root_child3.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child3.getComputedHeight()).toBe(10);
|
|
|
|
|
|
|
|
expect(root_child4.getComputedLeft()).toBe(80);
|
|
|
|
expect(root_child4.getComputedTop()).toBe(90);
|
|
|
|
expect(root_child4.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child4.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-02-11 08:32:48 -08:00
|
|
|
});
|
2022-12-24 00:35:10 -08:00
|
|
|
test("align_content_spacearound", function () {
|
|
|
|
const config = Yoga.Config.create();
|
2017-03-28 10:28:53 -07:00
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2022-12-24 00:35:10 -08:00
|
|
|
const root = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
|
|
|
root.setAlignContent(Yoga.ALIGN_SPACE_AROUND);
|
|
|
|
root.setFlexWrap(Yoga.WRAP_WRAP);
|
|
|
|
root.setWidth(140);
|
|
|
|
root.setHeight(120);
|
|
|
|
|
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.setWidth(50);
|
|
|
|
root_child0.setHeight(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.setWidth(50);
|
|
|
|
root_child1.setHeight(10);
|
|
|
|
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(10);
|
|
|
|
root.insertChild(root_child2, 2);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child3 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child3.setWidth(50);
|
|
|
|
root_child3.setHeight(10);
|
|
|
|
root.insertChild(root_child3, 3);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child4 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child4.setWidth(50);
|
|
|
|
root_child4.setHeight(10);
|
|
|
|
root.insertChild(root_child4, 4);
|
|
|
|
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(140);
|
|
|
|
expect(root.getComputedHeight()).toBe(120);
|
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(15);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(10);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child1.getComputedLeft()).toBe(50);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(15);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(10);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child2.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child2.getComputedTop()).toBe(55);
|
|
|
|
expect(root_child2.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child2.getComputedHeight()).toBe(10);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child3.getComputedLeft()).toBe(50);
|
|
|
|
expect(root_child3.getComputedTop()).toBe(55);
|
|
|
|
expect(root_child3.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child3.getComputedHeight()).toBe(10);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child4.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child4.getComputedTop()).toBe(95);
|
|
|
|
expect(root_child4.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child4.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(140);
|
|
|
|
expect(root.getComputedHeight()).toBe(120);
|
|
|
|
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(90);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(15);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(10);
|
|
|
|
|
|
|
|
expect(root_child1.getComputedLeft()).toBe(40);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(15);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(10);
|
|
|
|
|
|
|
|
expect(root_child2.getComputedLeft()).toBe(90);
|
|
|
|
expect(root_child2.getComputedTop()).toBe(55);
|
|
|
|
expect(root_child2.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child2.getComputedHeight()).toBe(10);
|
|
|
|
|
|
|
|
expect(root_child3.getComputedLeft()).toBe(40);
|
|
|
|
expect(root_child3.getComputedTop()).toBe(55);
|
|
|
|
expect(root_child3.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child3.getComputedHeight()).toBe(10);
|
|
|
|
|
|
|
|
expect(root_child4.getComputedLeft()).toBe(90);
|
|
|
|
expect(root_child4.getComputedTop()).toBe(95);
|
|
|
|
expect(root_child4.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child4.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-02-11 08:32:48 -08:00
|
|
|
});
|
2022-12-24 00:35:10 -08:00
|
|
|
test("align_content_stretch_row", function () {
|
|
|
|
const config = Yoga.Config.create();
|
2017-03-28 10:28:53 -07:00
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2022-12-24 00:35:10 -08:00
|
|
|
const root = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
|
|
|
root.setAlignContent(Yoga.ALIGN_STRETCH);
|
|
|
|
root.setFlexWrap(Yoga.WRAP_WRAP);
|
|
|
|
root.setWidth(150);
|
|
|
|
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.setWidth(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.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.insertChild(root_child2, 2);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child3 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child3.setWidth(50);
|
|
|
|
root.insertChild(root_child3, 3);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child4 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child4.setWidth(50);
|
|
|
|
root.insertChild(root_child4, 4);
|
|
|
|
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(150);
|
|
|
|
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(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(50);
|
|
|
|
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
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child2.getComputedLeft()).toBe(100);
|
|
|
|
expect(root_child2.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child2.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child2.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child3.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child3.getComputedTop()).toBe(50);
|
|
|
|
expect(root_child3.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child3.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child4.getComputedLeft()).toBe(50);
|
|
|
|
expect(root_child4.getComputedTop()).toBe(50);
|
|
|
|
expect(root_child4.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child4.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(150);
|
|
|
|
expect(root.getComputedHeight()).toBe(100);
|
|
|
|
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(100);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(50);
|
|
|
|
|
|
|
|
expect(root_child1.getComputedLeft()).toBe(50);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(50);
|
|
|
|
|
|
|
|
expect(root_child2.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child2.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child2.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child2.getComputedHeight()).toBe(50);
|
|
|
|
|
|
|
|
expect(root_child3.getComputedLeft()).toBe(100);
|
|
|
|
expect(root_child3.getComputedTop()).toBe(50);
|
|
|
|
expect(root_child3.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child3.getComputedHeight()).toBe(50);
|
|
|
|
|
|
|
|
expect(root_child4.getComputedLeft()).toBe(50);
|
|
|
|
expect(root_child4.getComputedTop()).toBe(50);
|
|
|
|
expect(root_child4.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child4.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 09:16:59 -08:00
|
|
|
});
|
2022-12-24 00:35:10 -08:00
|
|
|
test("align_content_stretch_row_with_children", function () {
|
|
|
|
const config = Yoga.Config.create();
|
2017-03-28 10:28:53 -07:00
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2022-12-24 00:35:10 -08:00
|
|
|
const root = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
|
|
|
root.setAlignContent(Yoga.ALIGN_STRETCH);
|
|
|
|
root.setFlexWrap(Yoga.WRAP_WRAP);
|
|
|
|
root.setWidth(150);
|
|
|
|
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.setWidth(50);
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child0_child0 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child0_child0.setFlexGrow(1);
|
|
|
|
root_child0_child0.setFlexShrink(1);
|
|
|
|
root_child0_child0.setFlexBasis("0%");
|
|
|
|
root_child0.insertChild(root_child0_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.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.insertChild(root_child2, 2);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child3 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child3.setWidth(50);
|
|
|
|
root.insertChild(root_child3, 3);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child4 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child4.setWidth(50);
|
|
|
|
root.insertChild(root_child4, 4);
|
|
|
|
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(150);
|
|
|
|
expect(root.getComputedHeight()).toBe(100);
|
|
|
|
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(50);
|
|
|
|
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child0_child0.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child0_child0.getComputedHeight()).toBe(50);
|
|
|
|
|
|
|
|
expect(root_child1.getComputedLeft()).toBe(50);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(50);
|
|
|
|
|
|
|
|
expect(root_child2.getComputedLeft()).toBe(100);
|
|
|
|
expect(root_child2.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child2.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child2.getComputedHeight()).toBe(50);
|
|
|
|
|
|
|
|
expect(root_child3.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child3.getComputedTop()).toBe(50);
|
|
|
|
expect(root_child3.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child3.getComputedHeight()).toBe(50);
|
|
|
|
|
|
|
|
expect(root_child4.getComputedLeft()).toBe(50);
|
|
|
|
expect(root_child4.getComputedTop()).toBe(50);
|
|
|
|
expect(root_child4.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child4.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(150);
|
|
|
|
expect(root.getComputedHeight()).toBe(100);
|
|
|
|
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(100);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(50);
|
|
|
|
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child0_child0.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child0_child0.getComputedHeight()).toBe(50);
|
|
|
|
|
|
|
|
expect(root_child1.getComputedLeft()).toBe(50);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(50);
|
|
|
|
|
|
|
|
expect(root_child2.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child2.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child2.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child2.getComputedHeight()).toBe(50);
|
|
|
|
|
|
|
|
expect(root_child3.getComputedLeft()).toBe(100);
|
|
|
|
expect(root_child3.getComputedTop()).toBe(50);
|
|
|
|
expect(root_child3.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child3.getComputedHeight()).toBe(50);
|
|
|
|
|
|
|
|
expect(root_child4.getComputedLeft()).toBe(50);
|
|
|
|
expect(root_child4.getComputedTop()).toBe(50);
|
|
|
|
expect(root_child4.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child4.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 09:16:59 -08:00
|
|
|
});
|
2022-12-24 00:35:10 -08:00
|
|
|
test("align_content_stretch_row_with_flex", function () {
|
|
|
|
const config = Yoga.Config.create();
|
2017-03-28 10:28:53 -07:00
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2022-12-24 00:35:10 -08:00
|
|
|
const root = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
|
|
|
root.setAlignContent(Yoga.ALIGN_STRETCH);
|
|
|
|
root.setFlexWrap(Yoga.WRAP_WRAP);
|
|
|
|
root.setWidth(150);
|
|
|
|
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.setWidth(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.setFlexGrow(1);
|
|
|
|
root_child1.setFlexShrink(1);
|
|
|
|
root_child1.setFlexBasis("0%");
|
|
|
|
root_child1.setWidth(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.insertChild(root_child2, 2);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child3 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child3.setFlexGrow(1);
|
|
|
|
root_child3.setFlexShrink(1);
|
|
|
|
root_child3.setFlexBasis("0%");
|
|
|
|
root_child3.setWidth(50);
|
|
|
|
root.insertChild(root_child3, 3);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child4 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child4.setWidth(50);
|
|
|
|
root.insertChild(root_child4, 4);
|
|
|
|
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(150);
|
|
|
|
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(50);
|
|
|
|
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(50);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(0);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(100);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child2.getComputedLeft()).toBe(50);
|
|
|
|
expect(root_child2.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child2.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child2.getComputedHeight()).toBe(100);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child3.getComputedLeft()).toBe(100);
|
|
|
|
expect(root_child3.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child3.getComputedWidth()).toBe(0);
|
|
|
|
expect(root_child3.getComputedHeight()).toBe(100);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child4.getComputedLeft()).toBe(100);
|
|
|
|
expect(root_child4.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child4.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child4.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(150);
|
|
|
|
expect(root.getComputedHeight()).toBe(100);
|
|
|
|
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(100);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(100);
|
|
|
|
|
|
|
|
expect(root_child1.getComputedLeft()).toBe(100);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(0);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(100);
|
|
|
|
|
|
|
|
expect(root_child2.getComputedLeft()).toBe(50);
|
|
|
|
expect(root_child2.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child2.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child2.getComputedHeight()).toBe(100);
|
|
|
|
|
|
|
|
expect(root_child3.getComputedLeft()).toBe(50);
|
|
|
|
expect(root_child3.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child3.getComputedWidth()).toBe(0);
|
|
|
|
expect(root_child3.getComputedHeight()).toBe(100);
|
|
|
|
|
|
|
|
expect(root_child4.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child4.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child4.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child4.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-02-14 09:16:59 -08:00
|
|
|
});
|
2022-12-24 00:35:10 -08:00
|
|
|
test("align_content_stretch_row_with_flex_no_shrink", function () {
|
|
|
|
const config = Yoga.Config.create();
|
2017-03-28 10:28:53 -07:00
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2022-12-24 00:35:10 -08:00
|
|
|
const root = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
|
|
|
root.setAlignContent(Yoga.ALIGN_STRETCH);
|
|
|
|
root.setFlexWrap(Yoga.WRAP_WRAP);
|
|
|
|
root.setWidth(150);
|
|
|
|
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.setWidth(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.setFlexGrow(1);
|
|
|
|
root_child1.setFlexShrink(1);
|
|
|
|
root_child1.setFlexBasis("0%");
|
|
|
|
root_child1.setWidth(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.insertChild(root_child2, 2);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child3 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child3.setFlexGrow(1);
|
|
|
|
root_child3.setFlexBasis("0%");
|
|
|
|
root_child3.setWidth(50);
|
|
|
|
root.insertChild(root_child3, 3);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child4 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child4.setWidth(50);
|
|
|
|
root.insertChild(root_child4, 4);
|
|
|
|
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(150);
|
|
|
|
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(50);
|
|
|
|
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(50);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(0);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(100);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child2.getComputedLeft()).toBe(50);
|
|
|
|
expect(root_child2.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child2.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child2.getComputedHeight()).toBe(100);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child3.getComputedLeft()).toBe(100);
|
|
|
|
expect(root_child3.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child3.getComputedWidth()).toBe(0);
|
|
|
|
expect(root_child3.getComputedHeight()).toBe(100);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child4.getComputedLeft()).toBe(100);
|
|
|
|
expect(root_child4.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child4.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child4.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(150);
|
|
|
|
expect(root.getComputedHeight()).toBe(100);
|
|
|
|
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(100);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(100);
|
|
|
|
|
|
|
|
expect(root_child1.getComputedLeft()).toBe(100);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(0);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(100);
|
|
|
|
|
|
|
|
expect(root_child2.getComputedLeft()).toBe(50);
|
|
|
|
expect(root_child2.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child2.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child2.getComputedHeight()).toBe(100);
|
|
|
|
|
|
|
|
expect(root_child3.getComputedLeft()).toBe(50);
|
|
|
|
expect(root_child3.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child3.getComputedWidth()).toBe(0);
|
|
|
|
expect(root_child3.getComputedHeight()).toBe(100);
|
|
|
|
|
|
|
|
expect(root_child4.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child4.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child4.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child4.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-02-14 09:16:59 -08:00
|
|
|
});
|
2022-12-24 00:35:10 -08:00
|
|
|
test("align_content_stretch_row_with_margin", function () {
|
|
|
|
const config = Yoga.Config.create();
|
2017-03-28 10:28:53 -07:00
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2022-12-24 00:35:10 -08:00
|
|
|
const root = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
|
|
|
root.setAlignContent(Yoga.ALIGN_STRETCH);
|
|
|
|
root.setFlexWrap(Yoga.WRAP_WRAP);
|
|
|
|
root.setWidth(150);
|
|
|
|
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.setWidth(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_LEFT, 10);
|
|
|
|
root_child1.setMargin(Yoga.EDGE_TOP, 10);
|
|
|
|
root_child1.setMargin(Yoga.EDGE_RIGHT, 10);
|
|
|
|
root_child1.setMargin(Yoga.EDGE_BOTTOM, 10);
|
|
|
|
root_child1.setWidth(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.insertChild(root_child2, 2);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child3 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child3.setMargin(Yoga.EDGE_LEFT, 10);
|
|
|
|
root_child3.setMargin(Yoga.EDGE_TOP, 10);
|
|
|
|
root_child3.setMargin(Yoga.EDGE_RIGHT, 10);
|
|
|
|
root_child3.setMargin(Yoga.EDGE_BOTTOM, 10);
|
|
|
|
root_child3.setWidth(50);
|
|
|
|
root.insertChild(root_child3, 3);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child4 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child4.setWidth(50);
|
|
|
|
root.insertChild(root_child4, 4);
|
|
|
|
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(150);
|
|
|
|
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(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(40);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child1.getComputedLeft()).toBe(60);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(10);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(20);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child2.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child2.getComputedTop()).toBe(40);
|
|
|
|
expect(root_child2.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child2.getComputedHeight()).toBe(40);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child3.getComputedLeft()).toBe(60);
|
|
|
|
expect(root_child3.getComputedTop()).toBe(50);
|
|
|
|
expect(root_child3.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child3.getComputedHeight()).toBe(20);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child4.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child4.getComputedTop()).toBe(80);
|
|
|
|
expect(root_child4.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child4.getComputedHeight()).toBe(20);
|
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(150);
|
|
|
|
expect(root.getComputedHeight()).toBe(100);
|
|
|
|
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(100);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(40);
|
|
|
|
|
|
|
|
expect(root_child1.getComputedLeft()).toBe(40);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(10);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(20);
|
|
|
|
|
|
|
|
expect(root_child2.getComputedLeft()).toBe(100);
|
|
|
|
expect(root_child2.getComputedTop()).toBe(40);
|
|
|
|
expect(root_child2.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child2.getComputedHeight()).toBe(40);
|
|
|
|
|
|
|
|
expect(root_child3.getComputedLeft()).toBe(40);
|
|
|
|
expect(root_child3.getComputedTop()).toBe(50);
|
|
|
|
expect(root_child3.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child3.getComputedHeight()).toBe(20);
|
|
|
|
|
|
|
|
expect(root_child4.getComputedLeft()).toBe(100);
|
|
|
|
expect(root_child4.getComputedTop()).toBe(80);
|
|
|
|
expect(root_child4.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child4.getComputedHeight()).toBe(20);
|
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 09:16:59 -08:00
|
|
|
});
|
2022-12-24 00:35:10 -08:00
|
|
|
test("align_content_stretch_row_with_padding", function () {
|
|
|
|
const config = Yoga.Config.create();
|
2017-03-28 10:28:53 -07:00
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2022-12-24 00:35:10 -08:00
|
|
|
const root = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
|
|
|
root.setAlignContent(Yoga.ALIGN_STRETCH);
|
|
|
|
root.setFlexWrap(Yoga.WRAP_WRAP);
|
|
|
|
root.setWidth(150);
|
|
|
|
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.setWidth(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.setPadding(Yoga.EDGE_LEFT, 10);
|
|
|
|
root_child1.setPadding(Yoga.EDGE_TOP, 10);
|
|
|
|
root_child1.setPadding(Yoga.EDGE_RIGHT, 10);
|
|
|
|
root_child1.setPadding(Yoga.EDGE_BOTTOM, 10);
|
|
|
|
root_child1.setWidth(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.insertChild(root_child2, 2);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child3 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child3.setPadding(Yoga.EDGE_LEFT, 10);
|
|
|
|
root_child3.setPadding(Yoga.EDGE_TOP, 10);
|
|
|
|
root_child3.setPadding(Yoga.EDGE_RIGHT, 10);
|
|
|
|
root_child3.setPadding(Yoga.EDGE_BOTTOM, 10);
|
|
|
|
root_child3.setWidth(50);
|
|
|
|
root.insertChild(root_child3, 3);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child4 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child4.setWidth(50);
|
|
|
|
root.insertChild(root_child4, 4);
|
|
|
|
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(150);
|
|
|
|
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(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(50);
|
|
|
|
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
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child2.getComputedLeft()).toBe(100);
|
|
|
|
expect(root_child2.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child2.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child2.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child3.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child3.getComputedTop()).toBe(50);
|
|
|
|
expect(root_child3.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child3.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child4.getComputedLeft()).toBe(50);
|
|
|
|
expect(root_child4.getComputedTop()).toBe(50);
|
|
|
|
expect(root_child4.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child4.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(150);
|
|
|
|
expect(root.getComputedHeight()).toBe(100);
|
|
|
|
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(100);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(50);
|
|
|
|
|
|
|
|
expect(root_child1.getComputedLeft()).toBe(50);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(50);
|
|
|
|
|
|
|
|
expect(root_child2.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child2.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child2.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child2.getComputedHeight()).toBe(50);
|
|
|
|
|
|
|
|
expect(root_child3.getComputedLeft()).toBe(100);
|
|
|
|
expect(root_child3.getComputedTop()).toBe(50);
|
|
|
|
expect(root_child3.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child3.getComputedHeight()).toBe(50);
|
|
|
|
|
|
|
|
expect(root_child4.getComputedLeft()).toBe(50);
|
|
|
|
expect(root_child4.getComputedTop()).toBe(50);
|
|
|
|
expect(root_child4.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child4.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 09:16:59 -08:00
|
|
|
});
|
2022-12-24 00:35:10 -08:00
|
|
|
test("align_content_stretch_row_with_single_row", function () {
|
|
|
|
const config = Yoga.Config.create();
|
2017-03-28 10:28:53 -07:00
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2022-12-24 00:35:10 -08:00
|
|
|
const root = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
|
|
|
root.setAlignContent(Yoga.ALIGN_STRETCH);
|
|
|
|
root.setFlexWrap(Yoga.WRAP_WRAP);
|
|
|
|
root.setWidth(150);
|
|
|
|
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.setWidth(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.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(150);
|
|
|
|
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(50);
|
|
|
|
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(50);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
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(150);
|
|
|
|
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(100);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(50);
|
|
|
|
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(50);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
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-02-14 09:16:59 -08:00
|
|
|
});
|
2022-12-24 00:35:10 -08:00
|
|
|
test("align_content_stretch_row_with_fixed_height", function () {
|
|
|
|
const config = Yoga.Config.create();
|
2017-03-28 10:28:53 -07:00
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2022-12-24 00:35:10 -08:00
|
|
|
const root = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
|
|
|
root.setAlignContent(Yoga.ALIGN_STRETCH);
|
|
|
|
root.setFlexWrap(Yoga.WRAP_WRAP);
|
|
|
|
root.setWidth(150);
|
|
|
|
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.setWidth(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(60);
|
|
|
|
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.insertChild(root_child2, 2);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child3 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child3.setWidth(50);
|
|
|
|
root.insertChild(root_child3, 3);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child4 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child4.setWidth(50);
|
|
|
|
root.insertChild(root_child4, 4);
|
|
|
|
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(150);
|
|
|
|
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(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(80);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child1.getComputedLeft()).toBe(50);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(60);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child2.getComputedLeft()).toBe(100);
|
|
|
|
expect(root_child2.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child2.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child2.getComputedHeight()).toBe(80);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child3.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child3.getComputedTop()).toBe(80);
|
|
|
|
expect(root_child3.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child3.getComputedHeight()).toBe(20);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child4.getComputedLeft()).toBe(50);
|
|
|
|
expect(root_child4.getComputedTop()).toBe(80);
|
|
|
|
expect(root_child4.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child4.getComputedHeight()).toBe(20);
|
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(150);
|
|
|
|
expect(root.getComputedHeight()).toBe(100);
|
|
|
|
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(100);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(80);
|
|
|
|
|
|
|
|
expect(root_child1.getComputedLeft()).toBe(50);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(60);
|
|
|
|
|
|
|
|
expect(root_child2.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child2.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child2.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child2.getComputedHeight()).toBe(80);
|
|
|
|
|
|
|
|
expect(root_child3.getComputedLeft()).toBe(100);
|
|
|
|
expect(root_child3.getComputedTop()).toBe(80);
|
|
|
|
expect(root_child3.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child3.getComputedHeight()).toBe(20);
|
|
|
|
|
|
|
|
expect(root_child4.getComputedLeft()).toBe(50);
|
|
|
|
expect(root_child4.getComputedTop()).toBe(80);
|
|
|
|
expect(root_child4.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child4.getComputedHeight()).toBe(20);
|
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 09:16:59 -08:00
|
|
|
});
|
2022-12-24 00:35:10 -08:00
|
|
|
test("align_content_stretch_row_with_max_height", function () {
|
|
|
|
const config = Yoga.Config.create();
|
2017-03-28 10:28:53 -07:00
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2022-12-24 00:35:10 -08:00
|
|
|
const root = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
|
|
|
root.setAlignContent(Yoga.ALIGN_STRETCH);
|
|
|
|
root.setFlexWrap(Yoga.WRAP_WRAP);
|
|
|
|
root.setWidth(150);
|
|
|
|
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.setWidth(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.setMaxHeight(20);
|
|
|
|
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.insertChild(root_child2, 2);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child3 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child3.setWidth(50);
|
|
|
|
root.insertChild(root_child3, 3);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child4 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child4.setWidth(50);
|
|
|
|
root.insertChild(root_child4, 4);
|
|
|
|
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(150);
|
|
|
|
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(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(50);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(20);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child2.getComputedLeft()).toBe(100);
|
|
|
|
expect(root_child2.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child2.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child2.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child3.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child3.getComputedTop()).toBe(50);
|
|
|
|
expect(root_child3.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child3.getComputedHeight()).toBe(50);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child4.getComputedLeft()).toBe(50);
|
|
|
|
expect(root_child4.getComputedTop()).toBe(50);
|
|
|
|
expect(root_child4.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child4.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(150);
|
|
|
|
expect(root.getComputedHeight()).toBe(100);
|
|
|
|
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(100);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(50);
|
|
|
|
|
|
|
|
expect(root_child1.getComputedLeft()).toBe(50);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(20);
|
|
|
|
|
|
|
|
expect(root_child2.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child2.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child2.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child2.getComputedHeight()).toBe(50);
|
|
|
|
|
|
|
|
expect(root_child3.getComputedLeft()).toBe(100);
|
|
|
|
expect(root_child3.getComputedTop()).toBe(50);
|
|
|
|
expect(root_child3.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child3.getComputedHeight()).toBe(50);
|
|
|
|
|
|
|
|
expect(root_child4.getComputedLeft()).toBe(50);
|
|
|
|
expect(root_child4.getComputedTop()).toBe(50);
|
|
|
|
expect(root_child4.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child4.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 09:16:59 -08:00
|
|
|
});
|
2022-12-24 00:35:10 -08:00
|
|
|
test("align_content_stretch_row_with_min_height", function () {
|
|
|
|
const config = Yoga.Config.create();
|
2017-03-28 10:28:53 -07:00
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2022-12-24 00:35:10 -08:00
|
|
|
const root = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
|
|
|
root.setAlignContent(Yoga.ALIGN_STRETCH);
|
|
|
|
root.setFlexWrap(Yoga.WRAP_WRAP);
|
|
|
|
root.setWidth(150);
|
|
|
|
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.setWidth(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.setMinHeight(80);
|
|
|
|
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.insertChild(root_child2, 2);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child3 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child3.setWidth(50);
|
|
|
|
root.insertChild(root_child3, 3);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child4 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child4.setWidth(50);
|
|
|
|
root.insertChild(root_child4, 4);
|
|
|
|
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(150);
|
|
|
|
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(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(90);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child1.getComputedLeft()).toBe(50);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(90);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child2.getComputedLeft()).toBe(100);
|
|
|
|
expect(root_child2.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child2.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child2.getComputedHeight()).toBe(90);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child3.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child3.getComputedTop()).toBe(90);
|
|
|
|
expect(root_child3.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child3.getComputedHeight()).toBe(10);
|
2017-02-20 05:31:20 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child4.getComputedLeft()).toBe(50);
|
|
|
|
expect(root_child4.getComputedTop()).toBe(90);
|
|
|
|
expect(root_child4.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child4.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(150);
|
|
|
|
expect(root.getComputedHeight()).toBe(100);
|
|
|
|
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(100);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(90);
|
|
|
|
|
|
|
|
expect(root_child1.getComputedLeft()).toBe(50);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(90);
|
|
|
|
|
|
|
|
expect(root_child2.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child2.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child2.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child2.getComputedHeight()).toBe(90);
|
|
|
|
|
|
|
|
expect(root_child3.getComputedLeft()).toBe(100);
|
|
|
|
expect(root_child3.getComputedTop()).toBe(90);
|
|
|
|
expect(root_child3.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child3.getComputedHeight()).toBe(10);
|
|
|
|
|
|
|
|
expect(root_child4.getComputedLeft()).toBe(50);
|
|
|
|
expect(root_child4.getComputedTop()).toBe(90);
|
|
|
|
expect(root_child4.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child4.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-02-14 09:16:59 -08:00
|
|
|
});
|
2022-12-24 00:35:10 -08:00
|
|
|
test("align_content_stretch_column", function () {
|
|
|
|
const config = Yoga.Config.create();
|
2017-03-28 10:28:53 -07:00
|
|
|
|
2017-02-20 05:31:20 -08:00
|
|
|
try {
|
2022-12-24 00:35:10 -08:00
|
|
|
const root = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root.setAlignContent(Yoga.ALIGN_STRETCH);
|
|
|
|
root.setFlexWrap(Yoga.WRAP_WRAP);
|
|
|
|
root.setWidth(100);
|
|
|
|
root.setHeight(150);
|
|
|
|
|
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.setHeight(50);
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child0_child0 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child0_child0.setFlexGrow(1);
|
|
|
|
root_child0_child0.setFlexShrink(1);
|
|
|
|
root_child0_child0.setFlexBasis("0%");
|
|
|
|
root_child0.insertChild(root_child0_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_child1.setFlexShrink(1);
|
|
|
|
root_child1.setFlexBasis("0%");
|
|
|
|
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.setHeight(50);
|
|
|
|
root.insertChild(root_child2, 2);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child3 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child3.setHeight(50);
|
|
|
|
root.insertChild(root_child3, 3);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child4 = Yoga.Node.create(config);
|
2017-02-20 05:31:20 -08:00
|
|
|
root_child4.setHeight(50);
|
|
|
|
root.insertChild(root_child4, 4);
|
|
|
|
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(150);
|
|
|
|
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(50);
|
|
|
|
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child0_child0.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child0_child0.getComputedHeight()).toBe(50);
|
|
|
|
|
|
|
|
expect(root_child1.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(50);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(0);
|
|
|
|
|
|
|
|
expect(root_child2.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child2.getComputedTop()).toBe(50);
|
|
|
|
expect(root_child2.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child2.getComputedHeight()).toBe(50);
|
|
|
|
|
|
|
|
expect(root_child3.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child3.getComputedTop()).toBe(100);
|
|
|
|
expect(root_child3.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child3.getComputedHeight()).toBe(50);
|
|
|
|
|
|
|
|
expect(root_child4.getComputedLeft()).toBe(50);
|
|
|
|
expect(root_child4.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child4.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child4.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(100);
|
|
|
|
expect(root.getComputedHeight()).toBe(150);
|
|
|
|
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(50);
|
|
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child0.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child0.getComputedHeight()).toBe(50);
|
|
|
|
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child0_child0.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child0_child0.getComputedHeight()).toBe(50);
|
|
|
|
|
|
|
|
expect(root_child1.getComputedLeft()).toBe(50);
|
|
|
|
expect(root_child1.getComputedTop()).toBe(50);
|
|
|
|
expect(root_child1.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child1.getComputedHeight()).toBe(0);
|
|
|
|
|
|
|
|
expect(root_child2.getComputedLeft()).toBe(50);
|
|
|
|
expect(root_child2.getComputedTop()).toBe(50);
|
|
|
|
expect(root_child2.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child2.getComputedHeight()).toBe(50);
|
|
|
|
|
|
|
|
expect(root_child3.getComputedLeft()).toBe(50);
|
|
|
|
expect(root_child3.getComputedTop()).toBe(100);
|
|
|
|
expect(root_child3.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child3.getComputedHeight()).toBe(50);
|
|
|
|
|
|
|
|
expect(root_child4.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child4.getComputedTop()).toBe(0);
|
|
|
|
expect(root_child4.getComputedWidth()).toBe(50);
|
|
|
|
expect(root_child4.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 09:16:59 -08:00
|
|
|
});
|
2022-12-24 00:35:10 -08:00
|
|
|
test("align_content_stretch_is_not_overriding_align_items", function () {
|
|
|
|
const config = Yoga.Config.create();
|
2017-03-28 10:28:53 -07:00
|
|
|
|
2017-02-23 08:25:16 -08:00
|
|
|
try {
|
2022-12-24 00:35:10 -08:00
|
|
|
const root = Yoga.Node.create(config);
|
2017-02-23 08:25:16 -08:00
|
|
|
root.setAlignContent(Yoga.ALIGN_STRETCH);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child0 = Yoga.Node.create(config);
|
2017-02-23 08:25:16 -08:00
|
|
|
root_child0.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
|
|
|
root_child0.setAlignContent(Yoga.ALIGN_STRETCH);
|
|
|
|
root_child0.setAlignItems(Yoga.ALIGN_CENTER);
|
|
|
|
root_child0.setWidth(100);
|
|
|
|
root_child0.setHeight(100);
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
const root_child0_child0 = Yoga.Node.create(config);
|
2017-02-23 08:25:16 -08:00
|
|
|
root_child0_child0.setAlignContent(Yoga.ALIGN_STRETCH);
|
|
|
|
root_child0_child0.setWidth(10);
|
|
|
|
root_child0_child0.setHeight(10);
|
|
|
|
root_child0.insertChild(root_child0_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-23 08:25:16 -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(100);
|
2017-02-23 08:25:16 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(0);
|
|
|
|
expect(root_child0_child0.getComputedTop()).toBe(45);
|
|
|
|
expect(root_child0_child0.getComputedWidth()).toBe(10);
|
|
|
|
expect(root_child0_child0.getComputedHeight()).toBe(10);
|
2017-02-23 08:25:16 -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-23 08:25:16 -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(100);
|
2017-02-23 08:25:16 -08:00
|
|
|
|
2022-12-24 00:35:10 -08:00
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(90);
|
|
|
|
expect(root_child0_child0.getComputedTop()).toBe(45);
|
|
|
|
expect(root_child0_child0.getComputedWidth()).toBe(10);
|
|
|
|
expect(root_child0_child0.getComputedHeight()).toBe(10);
|
2017-02-23 08:25:16 -08:00
|
|
|
} finally {
|
|
|
|
if (typeof root !== "undefined") {
|
|
|
|
root.freeRecursive();
|
|
|
|
}
|
2017-03-28 10:28:53 -07:00
|
|
|
|
|
|
|
config.free();
|
2017-02-23 08:25:16 -08:00
|
|
|
}
|
|
|
|
});
|