2019-06-06 19:36:56 -07: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.
|
2016-08-25 15:28:43 -07: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.
|
2016-08-25 15:28:43 -07: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
|
|
|
|
|
|
|
// clang-format off
|
2022-11-15 19:51:48 -08:00
|
|
|
// @generated by gentest/gentest.rb from gentest/fixtures/YGJustifyContentTest.html
|
2016-08-25 15:28:43 -07:00
|
|
|
|
|
|
|
#include <gtest/gtest.h>
|
2017-01-31 09:28:09 -08:00
|
|
|
#include <yoga/Yoga.h>
|
2016-08-25 15:28:43 -07:00
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
TEST(YogaTest, justify_content_row_flex_start) {
|
2017-03-01 09:19:55 -08:00
|
|
|
const YGConfigRef config = YGConfigNew();
|
2023-01-08 13:41:27 -08:00
|
|
|
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true);
|
2017-03-01 09:19:55 -08:00
|
|
|
|
|
|
|
const YGNodeRef root = YGNodeNewWithConfig(config);
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
|
|
|
|
YGNodeStyleSetWidth(root, 102);
|
|
|
|
YGNodeStyleSetHeight(root, 102);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeStyleSetWidth(root_child0, 10);
|
|
|
|
YGNodeInsertChild(root, root_child0, 0);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeStyleSetWidth(root_child1, 10);
|
|
|
|
YGNodeInsertChild(root, root_child1, 1);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeStyleSetWidth(root_child2, 10);
|
|
|
|
YGNodeInsertChild(root, root_child2, 2);
|
|
|
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child0));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child1));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child2));
|
|
|
|
|
|
|
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(92, YGNodeLayoutGetLeft(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child0));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(82, YGNodeLayoutGetLeft(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child1));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(72, YGNodeLayoutGetLeft(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child2));
|
|
|
|
|
|
|
|
YGNodeFreeRecursive(root);
|
2017-03-01 09:19:55 -08:00
|
|
|
|
|
|
|
YGConfigFree(config);
|
2016-08-25 15:28:43 -07:00
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
TEST(YogaTest, justify_content_row_flex_end) {
|
2017-03-01 09:19:55 -08:00
|
|
|
const YGConfigRef config = YGConfigNew();
|
2023-01-08 13:41:27 -08:00
|
|
|
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true);
|
2017-03-01 09:19:55 -08:00
|
|
|
|
|
|
|
const YGNodeRef root = YGNodeNewWithConfig(config);
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
|
|
|
|
YGNodeStyleSetJustifyContent(root, YGJustifyFlexEnd);
|
|
|
|
YGNodeStyleSetWidth(root, 102);
|
|
|
|
YGNodeStyleSetHeight(root, 102);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeStyleSetWidth(root_child0, 10);
|
|
|
|
YGNodeInsertChild(root, root_child0, 0);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeStyleSetWidth(root_child1, 10);
|
|
|
|
YGNodeInsertChild(root, root_child1, 1);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeStyleSetWidth(root_child2, 10);
|
|
|
|
YGNodeInsertChild(root, root_child2, 2);
|
|
|
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(72, YGNodeLayoutGetLeft(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child0));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(82, YGNodeLayoutGetLeft(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child1));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(92, YGNodeLayoutGetLeft(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child2));
|
|
|
|
|
|
|
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child0));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child1));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child2));
|
|
|
|
|
|
|
|
YGNodeFreeRecursive(root);
|
2017-03-01 09:19:55 -08:00
|
|
|
|
|
|
|
YGConfigFree(config);
|
2016-08-25 15:28:43 -07:00
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
TEST(YogaTest, justify_content_row_center) {
|
2017-03-01 09:19:55 -08:00
|
|
|
const YGConfigRef config = YGConfigNew();
|
2023-01-08 13:41:27 -08:00
|
|
|
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true);
|
2017-03-01 09:19:55 -08:00
|
|
|
|
|
|
|
const YGNodeRef root = YGNodeNewWithConfig(config);
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
|
|
|
|
YGNodeStyleSetJustifyContent(root, YGJustifyCenter);
|
|
|
|
YGNodeStyleSetWidth(root, 102);
|
|
|
|
YGNodeStyleSetHeight(root, 102);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeStyleSetWidth(root_child0, 10);
|
|
|
|
YGNodeInsertChild(root, root_child0, 0);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeStyleSetWidth(root_child1, 10);
|
|
|
|
YGNodeInsertChild(root, root_child1, 1);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeStyleSetWidth(root_child2, 10);
|
|
|
|
YGNodeInsertChild(root, root_child2, 2);
|
|
|
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(36, YGNodeLayoutGetLeft(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child0));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(46, YGNodeLayoutGetLeft(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child1));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(56, YGNodeLayoutGetLeft(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child2));
|
|
|
|
|
|
|
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(56, YGNodeLayoutGetLeft(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child0));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(46, YGNodeLayoutGetLeft(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child1));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(36, YGNodeLayoutGetLeft(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child2));
|
|
|
|
|
|
|
|
YGNodeFreeRecursive(root);
|
2017-03-01 09:19:55 -08:00
|
|
|
|
|
|
|
YGConfigFree(config);
|
2016-08-25 15:28:43 -07:00
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
TEST(YogaTest, justify_content_row_space_between) {
|
2017-03-01 09:19:55 -08:00
|
|
|
const YGConfigRef config = YGConfigNew();
|
2023-01-08 13:41:27 -08:00
|
|
|
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true);
|
2017-03-01 09:19:55 -08:00
|
|
|
|
|
|
|
const YGNodeRef root = YGNodeNewWithConfig(config);
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
|
|
|
|
YGNodeStyleSetJustifyContent(root, YGJustifySpaceBetween);
|
|
|
|
YGNodeStyleSetWidth(root, 102);
|
|
|
|
YGNodeStyleSetHeight(root, 102);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeStyleSetWidth(root_child0, 10);
|
|
|
|
YGNodeInsertChild(root, root_child0, 0);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeStyleSetWidth(root_child1, 10);
|
|
|
|
YGNodeInsertChild(root, root_child1, 1);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeStyleSetWidth(root_child2, 10);
|
|
|
|
YGNodeInsertChild(root, root_child2, 2);
|
|
|
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child0));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(46, YGNodeLayoutGetLeft(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child1));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(92, YGNodeLayoutGetLeft(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child2));
|
|
|
|
|
|
|
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(92, YGNodeLayoutGetLeft(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child0));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(46, YGNodeLayoutGetLeft(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child1));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child2));
|
|
|
|
|
|
|
|
YGNodeFreeRecursive(root);
|
2017-03-01 09:19:55 -08:00
|
|
|
|
|
|
|
YGConfigFree(config);
|
2016-08-25 15:28:43 -07:00
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
TEST(YogaTest, justify_content_row_space_around) {
|
2017-03-01 09:19:55 -08:00
|
|
|
const YGConfigRef config = YGConfigNew();
|
2023-01-08 13:41:27 -08:00
|
|
|
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true);
|
2017-03-01 09:19:55 -08:00
|
|
|
|
|
|
|
const YGNodeRef root = YGNodeNewWithConfig(config);
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
|
|
|
|
YGNodeStyleSetJustifyContent(root, YGJustifySpaceAround);
|
|
|
|
YGNodeStyleSetWidth(root, 102);
|
|
|
|
YGNodeStyleSetHeight(root, 102);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeStyleSetWidth(root_child0, 10);
|
|
|
|
YGNodeInsertChild(root, root_child0, 0);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeStyleSetWidth(root_child1, 10);
|
|
|
|
YGNodeInsertChild(root, root_child1, 1);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeStyleSetWidth(root_child2, 10);
|
|
|
|
YGNodeInsertChild(root, root_child2, 2);
|
|
|
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(12, YGNodeLayoutGetLeft(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child0));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(46, YGNodeLayoutGetLeft(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child1));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child2));
|
|
|
|
|
|
|
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child0));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(46, YGNodeLayoutGetLeft(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child1));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(12, YGNodeLayoutGetLeft(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root_child2));
|
|
|
|
|
|
|
|
YGNodeFreeRecursive(root);
|
2017-03-01 09:19:55 -08:00
|
|
|
|
|
|
|
YGConfigFree(config);
|
2016-08-25 15:28:43 -07:00
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
TEST(YogaTest, justify_content_column_flex_start) {
|
2017-03-01 09:19:55 -08:00
|
|
|
const YGConfigRef config = YGConfigNew();
|
2023-01-08 13:41:27 -08:00
|
|
|
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true);
|
2017-03-01 09:19:55 -08:00
|
|
|
|
|
|
|
const YGNodeRef root = YGNodeNewWithConfig(config);
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeStyleSetWidth(root, 102);
|
|
|
|
YGNodeStyleSetHeight(root, 102);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeStyleSetHeight(root_child0, 10);
|
|
|
|
YGNodeInsertChild(root, root_child0, 0);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
|
2017-11-27 03:40:01 -08:00
|
|
|
YGNodeStyleSetHeight(root_child1, 10);
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeInsertChild(root, root_child1, 1);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeStyleSetHeight(root_child2, 10);
|
|
|
|
YGNodeInsertChild(root, root_child2, 2);
|
|
|
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child1));
|
2017-11-27 03:40:01 -08:00
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1));
|
2016-12-03 04:40:18 -08:00
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2));
|
2017-11-27 03:40:01 -08:00
|
|
|
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child2));
|
2016-12-03 04:40:18 -08:00
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2));
|
|
|
|
|
|
|
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child1));
|
2017-11-27 03:40:01 -08:00
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1));
|
2016-12-03 04:40:18 -08:00
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2));
|
2017-11-27 03:40:01 -08:00
|
|
|
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child2));
|
2016-12-03 04:40:18 -08:00
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2));
|
|
|
|
|
|
|
|
YGNodeFreeRecursive(root);
|
2017-03-01 09:19:55 -08:00
|
|
|
|
|
|
|
YGConfigFree(config);
|
2016-08-25 15:28:43 -07:00
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
TEST(YogaTest, justify_content_column_flex_end) {
|
2017-03-01 09:19:55 -08:00
|
|
|
const YGConfigRef config = YGConfigNew();
|
2023-01-08 13:41:27 -08:00
|
|
|
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true);
|
2017-03-01 09:19:55 -08:00
|
|
|
|
|
|
|
const YGNodeRef root = YGNodeNewWithConfig(config);
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeStyleSetJustifyContent(root, YGJustifyFlexEnd);
|
|
|
|
YGNodeStyleSetWidth(root, 102);
|
|
|
|
YGNodeStyleSetHeight(root, 102);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeStyleSetHeight(root_child0, 10);
|
|
|
|
YGNodeInsertChild(root, root_child0, 0);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeStyleSetHeight(root_child1, 10);
|
|
|
|
YGNodeInsertChild(root, root_child1, 1);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeStyleSetHeight(root_child2, 10);
|
|
|
|
YGNodeInsertChild(root, root_child2, 2);
|
|
|
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(72, YGNodeLayoutGetTop(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(82, YGNodeLayoutGetTop(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(92, YGNodeLayoutGetTop(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2));
|
|
|
|
|
|
|
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(72, YGNodeLayoutGetTop(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(82, YGNodeLayoutGetTop(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(92, YGNodeLayoutGetTop(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2));
|
|
|
|
|
|
|
|
YGNodeFreeRecursive(root);
|
2017-03-01 09:19:55 -08:00
|
|
|
|
|
|
|
YGConfigFree(config);
|
2016-08-25 15:28:43 -07:00
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
TEST(YogaTest, justify_content_column_center) {
|
2017-03-01 09:19:55 -08:00
|
|
|
const YGConfigRef config = YGConfigNew();
|
2023-01-08 13:41:27 -08:00
|
|
|
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true);
|
2017-03-01 09:19:55 -08:00
|
|
|
|
|
|
|
const YGNodeRef root = YGNodeNewWithConfig(config);
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeStyleSetJustifyContent(root, YGJustifyCenter);
|
|
|
|
YGNodeStyleSetWidth(root, 102);
|
|
|
|
YGNodeStyleSetHeight(root, 102);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeStyleSetHeight(root_child0, 10);
|
|
|
|
YGNodeInsertChild(root, root_child0, 0);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeStyleSetHeight(root_child1, 10);
|
|
|
|
YGNodeInsertChild(root, root_child1, 1);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeStyleSetHeight(root_child2, 10);
|
|
|
|
YGNodeInsertChild(root, root_child2, 2);
|
|
|
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(36, YGNodeLayoutGetTop(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(46, YGNodeLayoutGetTop(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(56, YGNodeLayoutGetTop(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2));
|
|
|
|
|
|
|
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(36, YGNodeLayoutGetTop(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(46, YGNodeLayoutGetTop(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(56, YGNodeLayoutGetTop(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2));
|
|
|
|
|
|
|
|
YGNodeFreeRecursive(root);
|
2017-03-01 09:19:55 -08:00
|
|
|
|
|
|
|
YGConfigFree(config);
|
2016-08-25 15:28:43 -07:00
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
TEST(YogaTest, justify_content_column_space_between) {
|
2017-03-01 09:19:55 -08:00
|
|
|
const YGConfigRef config = YGConfigNew();
|
2023-01-08 13:41:27 -08:00
|
|
|
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true);
|
2017-03-01 09:19:55 -08:00
|
|
|
|
|
|
|
const YGNodeRef root = YGNodeNewWithConfig(config);
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeStyleSetJustifyContent(root, YGJustifySpaceBetween);
|
|
|
|
YGNodeStyleSetWidth(root, 102);
|
|
|
|
YGNodeStyleSetHeight(root, 102);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeStyleSetHeight(root_child0, 10);
|
|
|
|
YGNodeInsertChild(root, root_child0, 0);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeStyleSetHeight(root_child1, 10);
|
|
|
|
YGNodeInsertChild(root, root_child1, 1);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeStyleSetHeight(root_child2, 10);
|
|
|
|
YGNodeInsertChild(root, root_child2, 2);
|
|
|
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(46, YGNodeLayoutGetTop(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(92, YGNodeLayoutGetTop(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2));
|
|
|
|
|
|
|
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(46, YGNodeLayoutGetTop(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(92, YGNodeLayoutGetTop(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2));
|
|
|
|
|
|
|
|
YGNodeFreeRecursive(root);
|
2017-03-01 09:19:55 -08:00
|
|
|
|
|
|
|
YGConfigFree(config);
|
2016-08-25 15:28:43 -07:00
|
|
|
}
|
|
|
|
|
2016-12-03 04:40:18 -08:00
|
|
|
TEST(YogaTest, justify_content_column_space_around) {
|
2017-03-01 09:19:55 -08:00
|
|
|
const YGConfigRef config = YGConfigNew();
|
2023-01-08 13:41:27 -08:00
|
|
|
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true);
|
2017-03-01 09:19:55 -08:00
|
|
|
|
|
|
|
const YGNodeRef root = YGNodeNewWithConfig(config);
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeStyleSetJustifyContent(root, YGJustifySpaceAround);
|
|
|
|
YGNodeStyleSetWidth(root, 102);
|
|
|
|
YGNodeStyleSetHeight(root, 102);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeStyleSetHeight(root_child0, 10);
|
|
|
|
YGNodeInsertChild(root, root_child0, 0);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeStyleSetHeight(root_child1, 10);
|
|
|
|
YGNodeInsertChild(root, root_child1, 1);
|
|
|
|
|
2017-03-01 09:19:55 -08:00
|
|
|
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
|
2016-12-03 04:40:18 -08:00
|
|
|
YGNodeStyleSetHeight(root_child2, 10);
|
|
|
|
YGNodeInsertChild(root, root_child2, 2);
|
|
|
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(12, YGNodeLayoutGetTop(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(46, YGNodeLayoutGetTop(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2));
|
|
|
|
|
|
|
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(12, YGNodeLayoutGetTop(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(46, YGNodeLayoutGetTop(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2));
|
|
|
|
|
|
|
|
YGNodeFreeRecursive(root);
|
2017-03-01 09:19:55 -08:00
|
|
|
|
|
|
|
YGConfigFree(config);
|
2016-08-25 15:28:43 -07:00
|
|
|
}
|
2017-11-24 07:06:16 -08:00
|
|
|
|
|
|
|
TEST(YogaTest, justify_content_row_min_width_and_margin) {
|
|
|
|
const YGConfigRef config = YGConfigNew();
|
2023-01-08 13:41:27 -08:00
|
|
|
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true);
|
2017-11-24 07:06:16 -08:00
|
|
|
|
|
|
|
const YGNodeRef root = YGNodeNewWithConfig(config);
|
|
|
|
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
|
|
|
|
YGNodeStyleSetJustifyContent(root, YGJustifyCenter);
|
|
|
|
YGNodeStyleSetMargin(root, YGEdgeLeft, 100);
|
|
|
|
YGNodeStyleSetMinWidth(root, 50);
|
|
|
|
|
|
|
|
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
|
|
|
|
YGNodeStyleSetWidth(root_child0, 20);
|
|
|
|
YGNodeStyleSetHeight(root_child0, 20);
|
|
|
|
YGNodeInsertChild(root, root_child0, 0);
|
|
|
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
|
|
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root));
|
|
|
|
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(15, YGNodeLayoutGetLeft(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0));
|
|
|
|
|
|
|
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
|
|
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root));
|
|
|
|
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(15, YGNodeLayoutGetLeft(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0));
|
|
|
|
|
|
|
|
YGNodeFreeRecursive(root);
|
|
|
|
|
|
|
|
YGConfigFree(config);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(YogaTest, justify_content_row_max_width_and_margin) {
|
|
|
|
const YGConfigRef config = YGConfigNew();
|
2023-01-08 13:41:27 -08:00
|
|
|
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true);
|
2017-11-24 07:06:16 -08:00
|
|
|
|
|
|
|
const YGNodeRef root = YGNodeNewWithConfig(config);
|
|
|
|
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
|
|
|
|
YGNodeStyleSetJustifyContent(root, YGJustifyCenter);
|
|
|
|
YGNodeStyleSetMargin(root, YGEdgeLeft, 100);
|
|
|
|
YGNodeStyleSetWidth(root, 100);
|
|
|
|
YGNodeStyleSetMaxWidth(root, 80);
|
|
|
|
|
|
|
|
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
|
|
|
|
YGNodeStyleSetWidth(root_child0, 20);
|
|
|
|
YGNodeStyleSetHeight(root_child0, 20);
|
|
|
|
YGNodeInsertChild(root, root_child0, 0);
|
|
|
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
|
|
|
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetWidth(root));
|
|
|
|
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0));
|
|
|
|
|
|
|
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
|
|
|
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetWidth(root));
|
|
|
|
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0));
|
|
|
|
|
|
|
|
YGNodeFreeRecursive(root);
|
|
|
|
|
|
|
|
YGConfigFree(config);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(YogaTest, justify_content_column_min_height_and_margin) {
|
|
|
|
const YGConfigRef config = YGConfigNew();
|
2023-01-08 13:41:27 -08:00
|
|
|
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true);
|
2017-11-24 07:06:16 -08:00
|
|
|
|
|
|
|
const YGNodeRef root = YGNodeNewWithConfig(config);
|
|
|
|
YGNodeStyleSetJustifyContent(root, YGJustifyCenter);
|
|
|
|
YGNodeStyleSetMargin(root, YGEdgeTop, 100);
|
|
|
|
YGNodeStyleSetMinHeight(root, 50);
|
|
|
|
|
|
|
|
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
|
|
|
|
YGNodeStyleSetWidth(root_child0, 20);
|
|
|
|
YGNodeStyleSetHeight(root_child0, 20);
|
|
|
|
YGNodeInsertChild(root, root_child0, 0);
|
|
|
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
|
|
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root));
|
|
|
|
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root));
|
|
|
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(15, YGNodeLayoutGetTop(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0));
|
|
|
|
|
|
|
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
|
|
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root));
|
|
|
|
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root));
|
|
|
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(15, YGNodeLayoutGetTop(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0));
|
|
|
|
|
|
|
|
YGNodeFreeRecursive(root);
|
|
|
|
|
|
|
|
YGConfigFree(config);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(YogaTest, justify_content_colunn_max_height_and_margin) {
|
|
|
|
const YGConfigRef config = YGConfigNew();
|
2023-01-08 13:41:27 -08:00
|
|
|
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true);
|
2017-11-24 07:06:16 -08:00
|
|
|
|
|
|
|
const YGNodeRef root = YGNodeNewWithConfig(config);
|
|
|
|
YGNodeStyleSetJustifyContent(root, YGJustifyCenter);
|
|
|
|
YGNodeStyleSetMargin(root, YGEdgeTop, 100);
|
|
|
|
YGNodeStyleSetHeight(root, 100);
|
|
|
|
YGNodeStyleSetMaxHeight(root, 80);
|
|
|
|
|
|
|
|
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
|
|
|
|
YGNodeStyleSetWidth(root_child0, 20);
|
|
|
|
YGNodeStyleSetHeight(root_child0, 20);
|
|
|
|
YGNodeInsertChild(root, root_child0, 0);
|
|
|
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
|
|
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root));
|
|
|
|
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root));
|
|
|
|
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0));
|
|
|
|
|
|
|
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
|
|
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root));
|
|
|
|
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root));
|
|
|
|
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0));
|
|
|
|
|
|
|
|
YGNodeFreeRecursive(root);
|
|
|
|
|
|
|
|
YGConfigFree(config);
|
|
|
|
}
|
2017-11-27 03:40:01 -08:00
|
|
|
|
|
|
|
TEST(YogaTest, justify_content_column_space_evenly) {
|
|
|
|
const YGConfigRef config = YGConfigNew();
|
2023-01-08 13:41:27 -08:00
|
|
|
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true);
|
2017-11-27 03:40:01 -08:00
|
|
|
|
|
|
|
const YGNodeRef root = YGNodeNewWithConfig(config);
|
|
|
|
YGNodeStyleSetJustifyContent(root, YGJustifySpaceEvenly);
|
|
|
|
YGNodeStyleSetWidth(root, 102);
|
|
|
|
YGNodeStyleSetHeight(root, 102);
|
|
|
|
|
|
|
|
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
|
|
|
|
YGNodeStyleSetHeight(root_child0, 10);
|
|
|
|
YGNodeInsertChild(root, root_child0, 0);
|
|
|
|
|
|
|
|
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
|
|
|
|
YGNodeStyleSetHeight(root_child1, 10);
|
|
|
|
YGNodeInsertChild(root, root_child1, 1);
|
|
|
|
|
|
|
|
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
|
|
|
|
YGNodeStyleSetHeight(root_child2, 10);
|
|
|
|
YGNodeInsertChild(root, root_child2, 2);
|
|
|
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(18, YGNodeLayoutGetTop(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(46, YGNodeLayoutGetTop(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(74, YGNodeLayoutGetTop(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2));
|
|
|
|
|
|
|
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(18, YGNodeLayoutGetTop(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(46, YGNodeLayoutGetTop(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(74, YGNodeLayoutGetTop(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2));
|
|
|
|
|
|
|
|
YGNodeFreeRecursive(root);
|
|
|
|
|
|
|
|
YGConfigFree(config);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(YogaTest, justify_content_row_space_evenly) {
|
|
|
|
const YGConfigRef config = YGConfigNew();
|
2023-01-08 13:41:27 -08:00
|
|
|
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true);
|
2017-11-27 03:40:01 -08:00
|
|
|
|
|
|
|
const YGNodeRef root = YGNodeNewWithConfig(config);
|
|
|
|
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
|
|
|
|
YGNodeStyleSetJustifyContent(root, YGJustifySpaceEvenly);
|
|
|
|
YGNodeStyleSetWidth(root, 102);
|
|
|
|
YGNodeStyleSetHeight(root, 102);
|
|
|
|
|
|
|
|
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
|
|
|
|
YGNodeStyleSetHeight(root_child0, 10);
|
|
|
|
YGNodeInsertChild(root, root_child0, 0);
|
|
|
|
|
|
|
|
const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
|
|
|
|
YGNodeStyleSetHeight(root_child1, 10);
|
|
|
|
YGNodeInsertChild(root, root_child1, 1);
|
|
|
|
|
|
|
|
const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
|
|
|
|
YGNodeStyleSetHeight(root_child2, 10);
|
|
|
|
YGNodeInsertChild(root, root_child2, 2);
|
|
|
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(26, YGNodeLayoutGetLeft(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(51, YGNodeLayoutGetLeft(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(77, YGNodeLayoutGetLeft(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2));
|
|
|
|
|
|
|
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetWidth(root));
|
|
|
|
ASSERT_FLOAT_EQ(102, YGNodeLayoutGetHeight(root));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(77, YGNodeLayoutGetLeft(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(51, YGNodeLayoutGetLeft(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(26, YGNodeLayoutGetLeft(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child2));
|
|
|
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2));
|
|
|
|
|
|
|
|
YGNodeFreeRecursive(root);
|
|
|
|
|
|
|
|
YGConfigFree(config);
|
|
|
|
}
|
2018-10-31 10:13:02 -07: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
|
|
|
TEST(YogaTest, justify_content_min_width_with_padding_child_width_greater_than_parent) {
|
2018-10-31 10:13:02 -07:00
|
|
|
const YGConfigRef config = YGConfigNew();
|
2023-01-08 13:41:27 -08:00
|
|
|
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true);
|
2018-10-31 10:13:02 -07:00
|
|
|
|
|
|
|
const YGNodeRef root = YGNodeNewWithConfig(config);
|
|
|
|
YGNodeStyleSetAlignContent(root, YGAlignStretch);
|
|
|
|
YGNodeStyleSetWidth(root, 1000);
|
|
|
|
YGNodeStyleSetHeight(root, 1584);
|
|
|
|
|
|
|
|
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
|
|
|
|
YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow);
|
|
|
|
YGNodeStyleSetAlignContent(root_child0, YGAlignStretch);
|
|
|
|
YGNodeInsertChild(root, root_child0, 0);
|
|
|
|
|
|
|
|
const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
|
|
|
|
YGNodeStyleSetFlexDirection(root_child0_child0, YGFlexDirectionRow);
|
|
|
|
YGNodeStyleSetJustifyContent(root_child0_child0, YGJustifyCenter);
|
|
|
|
YGNodeStyleSetAlignContent(root_child0_child0, YGAlignStretch);
|
|
|
|
YGNodeStyleSetPadding(root_child0_child0, YGEdgeLeft, 100);
|
|
|
|
YGNodeStyleSetPadding(root_child0_child0, YGEdgeRight, 100);
|
|
|
|
YGNodeStyleSetMinWidth(root_child0_child0, 400);
|
|
|
|
YGNodeInsertChild(root_child0, root_child0_child0, 0);
|
|
|
|
|
|
|
|
const YGNodeRef root_child0_child0_child0 = YGNodeNewWithConfig(config);
|
|
|
|
YGNodeStyleSetFlexDirection(root_child0_child0_child0, YGFlexDirectionRow);
|
|
|
|
YGNodeStyleSetAlignContent(root_child0_child0_child0, YGAlignStretch);
|
|
|
|
YGNodeStyleSetWidth(root_child0_child0_child0, 300);
|
|
|
|
YGNodeStyleSetHeight(root_child0_child0_child0, 100);
|
|
|
|
YGNodeInsertChild(root_child0_child0, root_child0_child0_child0, 0);
|
|
|
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
|
|
|
ASSERT_FLOAT_EQ(1000, YGNodeLayoutGetWidth(root));
|
|
|
|
ASSERT_FLOAT_EQ(1584, YGNodeLayoutGetHeight(root));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(1000, YGNodeLayoutGetWidth(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
|
|
|
|
ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root_child0_child0));
|
|
|
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child0));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0_child0_child0));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0_child0));
|
|
|
|
ASSERT_FLOAT_EQ(300, YGNodeLayoutGetWidth(root_child0_child0_child0));
|
|
|
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child0_child0));
|
|
|
|
|
|
|
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
|
|
|
ASSERT_FLOAT_EQ(1000, YGNodeLayoutGetWidth(root));
|
|
|
|
ASSERT_FLOAT_EQ(1584, YGNodeLayoutGetHeight(root));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(1000, YGNodeLayoutGetWidth(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(500, YGNodeLayoutGetLeft(root_child0_child0));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
|
|
|
|
ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root_child0_child0));
|
|
|
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child0));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0_child0_child0));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0_child0));
|
|
|
|
ASSERT_FLOAT_EQ(300, YGNodeLayoutGetWidth(root_child0_child0_child0));
|
|
|
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child0_child0));
|
|
|
|
|
|
|
|
YGNodeFreeRecursive(root);
|
|
|
|
|
|
|
|
YGConfigFree(config);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
TEST(YogaTest, justify_content_min_width_with_padding_child_width_lower_than_parent) {
|
2018-10-31 10:13:02 -07:00
|
|
|
const YGConfigRef config = YGConfigNew();
|
2023-01-08 13:41:27 -08:00
|
|
|
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true);
|
2018-10-31 10:13:02 -07:00
|
|
|
|
|
|
|
const YGNodeRef root = YGNodeNewWithConfig(config);
|
|
|
|
YGNodeStyleSetAlignContent(root, YGAlignStretch);
|
|
|
|
YGNodeStyleSetWidth(root, 1080);
|
|
|
|
YGNodeStyleSetHeight(root, 1584);
|
|
|
|
|
|
|
|
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
|
|
|
|
YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow);
|
|
|
|
YGNodeStyleSetAlignContent(root_child0, YGAlignStretch);
|
|
|
|
YGNodeInsertChild(root, root_child0, 0);
|
|
|
|
|
|
|
|
const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
|
|
|
|
YGNodeStyleSetFlexDirection(root_child0_child0, YGFlexDirectionRow);
|
|
|
|
YGNodeStyleSetJustifyContent(root_child0_child0, YGJustifyCenter);
|
|
|
|
YGNodeStyleSetAlignContent(root_child0_child0, YGAlignStretch);
|
|
|
|
YGNodeStyleSetPadding(root_child0_child0, YGEdgeLeft, 100);
|
|
|
|
YGNodeStyleSetPadding(root_child0_child0, YGEdgeRight, 100);
|
|
|
|
YGNodeStyleSetMinWidth(root_child0_child0, 400);
|
|
|
|
YGNodeInsertChild(root_child0, root_child0_child0, 0);
|
|
|
|
|
|
|
|
const YGNodeRef root_child0_child0_child0 = YGNodeNewWithConfig(config);
|
|
|
|
YGNodeStyleSetFlexDirection(root_child0_child0_child0, YGFlexDirectionRow);
|
|
|
|
YGNodeStyleSetAlignContent(root_child0_child0_child0, YGAlignStretch);
|
|
|
|
YGNodeStyleSetWidth(root_child0_child0_child0, 199);
|
|
|
|
YGNodeStyleSetHeight(root_child0_child0_child0, 100);
|
|
|
|
YGNodeInsertChild(root_child0_child0, root_child0_child0_child0, 0);
|
|
|
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
|
|
|
ASSERT_FLOAT_EQ(1080, YGNodeLayoutGetWidth(root));
|
|
|
|
ASSERT_FLOAT_EQ(1584, YGNodeLayoutGetHeight(root));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(1080, YGNodeLayoutGetWidth(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
|
|
|
|
ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root_child0_child0));
|
|
|
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child0));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(101, YGNodeLayoutGetLeft(root_child0_child0_child0));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0_child0));
|
|
|
|
ASSERT_FLOAT_EQ(199, YGNodeLayoutGetWidth(root_child0_child0_child0));
|
|
|
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child0_child0));
|
|
|
|
|
|
|
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
|
|
|
ASSERT_FLOAT_EQ(1080, YGNodeLayoutGetWidth(root));
|
|
|
|
ASSERT_FLOAT_EQ(1584, YGNodeLayoutGetHeight(root));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(1080, YGNodeLayoutGetWidth(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(680, YGNodeLayoutGetLeft(root_child0_child0));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
|
|
|
|
ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root_child0_child0));
|
|
|
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child0));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(101, YGNodeLayoutGetLeft(root_child0_child0_child0));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0_child0));
|
|
|
|
ASSERT_FLOAT_EQ(199, YGNodeLayoutGetWidth(root_child0_child0_child0));
|
|
|
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child0_child0));
|
|
|
|
|
|
|
|
YGNodeFreeRecursive(root);
|
|
|
|
|
|
|
|
YGConfigFree(config);
|
|
|
|
}
|
Fixup hack for flex line size calculation (#1380)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1380
X-link: https://github.com/facebook/react-native/pull/39433
Back when rolling out flex gap, we encountered a bug where gap was added to the end of the main axis when a size was not specified.
During flex line justification/sizing, we calculate the amount of space that should be in between children. We erroneously add this, even after the last child element.
For `justify-content`, this space between children is derived from free space along the axis. The only time we have free space is if we had a dimension/dimension constraint already set on the parent. In this case, the extra space added to the end of the flex line is usually never noticed, because we bound `maxLineMainDim` to container dimension constraints at the end of layout, and the error doesn't effect how any children are positioned or sized.
There was at least one screenshot test where this issue showed up though, and I was able to add a slightly different repro where we may have free space without a definite dimension by enforcing a min dimension and not stretching.
{F1091401183}
The new reference is correct, and looking back at diffs, is what this seemed to originally look like when added three years ago. Seems like there may have been a potential regression, but I didn't spot anything suspicious when I looked around the code history.
`betweenMainDim` may still be set for `gap` even if we don't have a sized parent, which makes the extra space propagated to `maxLineMainDim` effect parent size.
Because we were in a code freeze, I opted to have us go with a solution just effecting flex gap, instead of the right one, in case there were any side effects. This cleans up the code to use the right calculation everywhere, and fixes a separate bug, where `endOfLineIndex` and `startOfLineIndex` may not be the last/first in the line if they are out of the layout flow (absolutely positioned, or display: none_
See the original conversation on https://github.com/facebook/yoga/pull/1188
Reviewed By: javache
Differential Revision: D49260049
fbshipit-source-id: 218552c5ff938668b9f257df7a1493e13ded4d0d
2023-09-14 20:26:31 -07:00
|
|
|
|
|
|
|
TEST(YogaTest, justify_content_space_between_indefinite_container_dim_with_free_space) {
|
|
|
|
const YGConfigRef config = YGConfigNew();
|
|
|
|
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true);
|
|
|
|
|
|
|
|
const YGNodeRef root = YGNodeNewWithConfig(config);
|
|
|
|
YGNodeStyleSetAlignItems(root, YGAlignCenter);
|
|
|
|
YGNodeStyleSetWidth(root, 300);
|
|
|
|
|
|
|
|
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
|
|
|
|
YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow);
|
|
|
|
YGNodeStyleSetJustifyContent(root_child0, YGJustifySpaceBetween);
|
|
|
|
YGNodeStyleSetMinWidth(root_child0, 200);
|
|
|
|
YGNodeInsertChild(root, root_child0, 0);
|
|
|
|
|
|
|
|
const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
|
|
|
|
YGNodeStyleSetWidth(root_child0_child0, 50);
|
|
|
|
YGNodeStyleSetHeight(root_child0_child0, 50);
|
|
|
|
YGNodeInsertChild(root_child0, root_child0_child0, 0);
|
|
|
|
|
|
|
|
const YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config);
|
|
|
|
YGNodeStyleSetWidth(root_child0_child1, 50);
|
|
|
|
YGNodeStyleSetHeight(root_child0_child1, 50);
|
|
|
|
YGNodeInsertChild(root_child0, root_child0_child1, 1);
|
|
|
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
|
|
|
ASSERT_FLOAT_EQ(300, YGNodeLayoutGetWidth(root));
|
|
|
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
|
|
|
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0_child0));
|
|
|
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0_child0));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(150, YGNodeLayoutGetLeft(root_child0_child1));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1));
|
|
|
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0_child1));
|
|
|
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0_child1));
|
|
|
|
|
|
|
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
|
|
|
ASSERT_FLOAT_EQ(300, YGNodeLayoutGetWidth(root));
|
|
|
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(150, YGNodeLayoutGetLeft(root_child0_child0));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
|
|
|
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0_child0));
|
|
|
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0_child0));
|
|
|
|
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child1));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1));
|
|
|
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0_child1));
|
|
|
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0_child1));
|
|
|
|
|
|
|
|
YGNodeFreeRecursive(root);
|
|
|
|
|
|
|
|
YGConfigFree(config);
|
|
|
|
}
|