From 8277df7e1fb8e89d8be0ce28d62977e3da94f5a8 Mon Sep 17 00:00:00 2001 From: Joe Vilches Date: Wed, 25 Sep 2024 15:46:55 -0700 Subject: [PATCH] Update gentest to account for box sizing (#1700) Summary: Pull Request resolved: https://github.com/facebook/yoga/pull/1700 tsia, need to teach gentest to write box sizing now. Reviewed By: NickGerleman Differential Revision: D63138372 fbshipit-source-id: 29072b3e602fe77edb14a8857a83e5bba4c92205 --- gentest/fixtures/YGBoxSizingTest.html | 3 + gentest/gentest-cpp.js | 11 +++ gentest/gentest-java.js | 9 +++ gentest/gentest-javascript.js | 10 +++ gentest/gentest.js | 18 ++++- .../com/facebook/yoga/YGBoxSizingTest.java | 68 ++++++++++++++++++ .../generated/YGAbsolutePositionTest.test.ts | 3 +- .../generated/YGAlignContentTest.test.ts | 3 +- .../tests/generated/YGAlignItemsTest.test.ts | 3 +- .../tests/generated/YGAlignSelfTest.test.ts | 3 +- .../tests/generated/YGAndroidNewsFeed.test.ts | 3 +- .../tests/generated/YGAspectRatioTest.test.ts | 3 +- .../tests/generated/YGBorderTest.test.ts | 3 +- .../tests/generated/YGBoxSizingTest.test.ts | 69 +++++++++++++++++++ .../tests/generated/YGDimensionTest.test.ts | 3 +- .../tests/generated/YGDisplayTest.test.ts | 3 +- .../generated/YGFlexDirectionTest.test.ts | 3 +- javascript/tests/generated/YGFlexTest.test.ts | 3 +- .../tests/generated/YGFlexWrapTest.test.ts | 3 +- javascript/tests/generated/YGGapTest.test.ts | 3 +- .../generated/YGIntrinsicSizeTest.test.ts | 3 +- .../generated/YGJustifyContentTest.test.ts | 3 +- .../tests/generated/YGMarginTest.test.ts | 3 +- .../generated/YGMinMaxDimensionTest.test.ts | 3 +- .../tests/generated/YGPaddingTest.test.ts | 3 +- .../tests/generated/YGPercentageTest.test.ts | 3 +- .../tests/generated/YGRoundingTest.test.ts | 3 +- .../generated/YGSizeOverflowTest.test.ts | 3 +- .../generated/YGStaticPositionTest.test.ts | 3 +- tests/generated/YGBoxSizingTest.cpp | 51 ++++++++++++++ 30 files changed, 281 insertions(+), 24 deletions(-) create mode 100644 gentest/fixtures/YGBoxSizingTest.html create mode 100644 java/tests/generated/com/facebook/yoga/YGBoxSizingTest.java create mode 100644 javascript/tests/generated/YGBoxSizingTest.test.ts create mode 100644 tests/generated/YGBoxSizingTest.cpp diff --git a/gentest/fixtures/YGBoxSizingTest.html b/gentest/fixtures/YGBoxSizingTest.html new file mode 100644 index 00000000..ce88f523 --- /dev/null +++ b/gentest/fixtures/YGBoxSizingTest.html @@ -0,0 +1,3 @@ +
+
diff --git a/gentest/gentest-cpp.js b/gentest/gentest-cpp.js index b29b8bfe..4dde8177 100644 --- a/gentest/gentest-cpp.js +++ b/gentest/gentest-cpp.js @@ -136,6 +136,9 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, { YGWrapWrap: {value: 'YGWrapWrap'}, YGWrapWrapReverse: {value: 'YGWrapWrapReverse'}, + YGBoxSizingBorderBox: {value: 'YGBoxSizingBorderBox'}, + YGBoxSizingContentBox: {value: 'YGBoxSizingContentBox'}, + YGUndefined: {value: 'YGUndefined'}, YGDisplayFlex: {value: 'YGDisplayFlex'}, @@ -512,6 +515,14 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, { }, }, + YGNodeStyleSetBoxSizing: { + value: function (nodeName, value) { + this.push( + 'YGNodeStyleSetBoxSizing(' + nodeName + ', ' + toValueCpp(value) + ');', + ); + }, + }, + YGNodeSetMeasureFunc: { value: function (nodeName, innerText) { this.push(`YGNodeSetContext(${nodeName}, (void*)"${innerText}");`); diff --git a/gentest/gentest-java.js b/gentest/gentest-java.js index ac0ce0f6..020d98e3 100644 --- a/gentest/gentest-java.js +++ b/gentest/gentest-java.js @@ -184,6 +184,9 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, { YGWrapWrap: {value: 'YogaWrap.WRAP'}, YGWrapWrapReverse: {value: 'YogaWrap.WRAP_REVERSE'}, + YGBoxSizingBorderBox: {value: 'YogaBoxSizing.BORDER_BOX'}, + YGBoxSizingContentBox: {value: 'YogaBoxSizing.CONTENT_BOX'}, + YGNodeCalculateLayout: { value: function (node, dir, _experiments) { this.push(node + '.setDirection(' + dir + ');'); @@ -473,6 +476,12 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, { }, }, + YGNodeStyleSetBoxSizing: { + value: function (nodeName, value) { + this.push(nodeName + '.setBoxSizing(' + toValueJava(value) + ');'); + }, + }, + YGNodeSetMeasureFunc: { value: function (nodeName, innerText) { this.push(`${nodeName}.setData("${innerText}");`); diff --git a/gentest/gentest-javascript.js b/gentest/gentest-javascript.js index c36cee6b..f79b76e5 100644 --- a/gentest/gentest-javascript.js +++ b/gentest/gentest-javascript.js @@ -30,6 +30,7 @@ JavascriptEmitter.prototype = Object.create(Emitter.prototype, { this.push('import {'); this.pushIndent(); this.push('Align,'); + this.push('BoxSizing,'); this.push('Direction,'); this.push('Display,'); this.push('Edge,'); @@ -171,6 +172,9 @@ JavascriptEmitter.prototype = Object.create(Emitter.prototype, { YGDisplayFlex: {value: 'Display.Flex'}, YGDisplayNone: {value: 'Display.None'}, + YGBoxSizingBorderBox: {value: 'BoxSizing.BorderBox'}, + YGBoxSizingContentBox: {value: 'BoxSizing.ContentBox'}, + YGNodeCalculateLayout: { value: function (node, dir, _experiments) { this.push(node + '.calculateLayout(undefined, undefined, ' + dir + ');'); @@ -410,6 +414,12 @@ JavascriptEmitter.prototype = Object.create(Emitter.prototype, { }, }, + YGNodeStyleSetBoxSizing: { + value: function (nodeName, value) { + this.push(nodeName + '.setBoxSizing(' + toValueJavascript(value) + ');'); + }, + }, + YGNodeSetMeasureFunc: { value: function (nodeName, innerText) { this.push( diff --git a/gentest/gentest.js b/gentest/gentest.js index 39408b6a..52fdca47 100755 --- a/gentest/gentest.js +++ b/gentest/gentest.js @@ -175,6 +175,7 @@ function checkDefaultValues() { {style: 'right', value: 'undefined'}, {style: 'bottom', value: 'undefined'}, {style: 'display', value: 'flex'}, + {style: 'box-sizing', value: 'border-box'}, ].forEach(item => { assert( isDefaultStyleValue(item.style, item.value), @@ -193,7 +194,6 @@ function setupTestTree( index, ) { e.emitTestTreePrologue(nodeName); - for (const style in node.style) { // Skip position info for root as it messes up tests if ( @@ -207,7 +207,6 @@ function setupTestTree( ) { continue; } - if (!isDefaultStyleValue(style, node.style[style])) { switch (style) { case 'aspect-ratio': @@ -520,6 +519,11 @@ function setupTestTree( case 'display': e.YGNodeStyleSetDisplay(nodeName, displayValue(e, node.style[style])); break; + case 'box-sizing': + e.YGNodeStyleSetBoxSizing( + nodeName, + boxSizingValue(e, node.style[style]), + ); } } } @@ -664,6 +668,15 @@ function displayValue(e, value) { } } +function boxSizingValue(e, value) { + switch (value) { + case 'border-box': + return e.YGBoxSizingBorderBox; + case 'content-box': + return e.YGBoxSizingContentBox; + } +} + const DEFAULT_STYLES = new Map(); function isDefaultStyleValue(style, value) { @@ -782,6 +795,7 @@ function getYogaStyle(node) { 'row-gap', 'display', 'aspect-ratio', + 'box-sizing', ].reduce((map, key) => { map[key] = node.style[key] || getComputedStyle(node, null).getPropertyValue(key); diff --git a/java/tests/generated/com/facebook/yoga/YGBoxSizingTest.java b/java/tests/generated/com/facebook/yoga/YGBoxSizingTest.java new file mode 100644 index 00000000..edc5b14b --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/YGBoxSizingTest.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @generated SignedSource<<1b72c10a32dce3a330fae20103be9846>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/YGBoxSizingTest.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class YGBoxSizingTest { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + @Ignore + public void test_box_sizing_content_box() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setPadding(YogaEdge.LEFT, 5); + root.setPadding(YogaEdge.TOP, 5); + root.setPadding(YogaEdge.RIGHT, 5); + root.setPadding(YogaEdge.BOTTOM, 5); + root.setBorder(YogaEdge.LEFT, 10f); + root.setBorder(YogaEdge.TOP, 10f); + root.setBorder(YogaEdge.RIGHT, 10f); + root.setBorder(YogaEdge.BOTTOM, 10f); + root.setWidth(100f); + root.setHeight(100f); + root.setBoxSizing(YogaBoxSizing.CONTENT_BOX); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(130f, root.getLayoutWidth(), 0.0f); + assertEquals(130f, root.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(130f, root.getLayoutWidth(), 0.0f); + assertEquals(130f, root.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/javascript/tests/generated/YGAbsolutePositionTest.test.ts b/javascript/tests/generated/YGAbsolutePositionTest.test.ts index c21771bc..694086e2 100644 --- a/javascript/tests/generated/YGAbsolutePositionTest.test.ts +++ b/javascript/tests/generated/YGAbsolutePositionTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<3ac965030750351f007587f3ae1dec10>> + * @generated SignedSource<<9deb466dfc94bb340137a9e6b5d5c63d>> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGAbsolutePositionTest.html */ @@ -12,6 +12,7 @@ import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' import Yoga from 'yoga-layout'; import { Align, + BoxSizing, Direction, Display, Edge, diff --git a/javascript/tests/generated/YGAlignContentTest.test.ts b/javascript/tests/generated/YGAlignContentTest.test.ts index 32d11081..dbe41b6a 100644 --- a/javascript/tests/generated/YGAlignContentTest.test.ts +++ b/javascript/tests/generated/YGAlignContentTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<> + * @generated SignedSource<<25f4cf395ff39619966d6f0ff993e99d>> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGAlignContentTest.html */ @@ -12,6 +12,7 @@ import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' import Yoga from 'yoga-layout'; import { Align, + BoxSizing, Direction, Display, Edge, diff --git a/javascript/tests/generated/YGAlignItemsTest.test.ts b/javascript/tests/generated/YGAlignItemsTest.test.ts index f9921c25..39c013a3 100644 --- a/javascript/tests/generated/YGAlignItemsTest.test.ts +++ b/javascript/tests/generated/YGAlignItemsTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<> + * @generated SignedSource<<075a0b67003e5c4a1f51bd99da71c700>> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGAlignItemsTest.html */ @@ -12,6 +12,7 @@ import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' import Yoga from 'yoga-layout'; import { Align, + BoxSizing, Direction, Display, Edge, diff --git a/javascript/tests/generated/YGAlignSelfTest.test.ts b/javascript/tests/generated/YGAlignSelfTest.test.ts index c631969e..5d2e49ec 100644 --- a/javascript/tests/generated/YGAlignSelfTest.test.ts +++ b/javascript/tests/generated/YGAlignSelfTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<> + * @generated SignedSource<<1badc9ed5a0cb8d9a4a1b23653cfbe58>> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGAlignSelfTest.html */ @@ -12,6 +12,7 @@ import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' import Yoga from 'yoga-layout'; import { Align, + BoxSizing, Direction, Display, Edge, diff --git a/javascript/tests/generated/YGAndroidNewsFeed.test.ts b/javascript/tests/generated/YGAndroidNewsFeed.test.ts index e6050cf0..488ed8d5 100644 --- a/javascript/tests/generated/YGAndroidNewsFeed.test.ts +++ b/javascript/tests/generated/YGAndroidNewsFeed.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<8f3c045b0df6a23f1d2fa54a255cb6f3>> + * @generated SignedSource<> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGAndroidNewsFeed.html */ @@ -12,6 +12,7 @@ import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' import Yoga from 'yoga-layout'; import { Align, + BoxSizing, Direction, Display, Edge, diff --git a/javascript/tests/generated/YGAspectRatioTest.test.ts b/javascript/tests/generated/YGAspectRatioTest.test.ts index 7dda850b..69a74278 100644 --- a/javascript/tests/generated/YGAspectRatioTest.test.ts +++ b/javascript/tests/generated/YGAspectRatioTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<> + * @generated SignedSource<<57064c3213fc22e0637ae5768ce6fea5>> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGAspectRatioTest.html */ @@ -12,6 +12,7 @@ import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' import Yoga from 'yoga-layout'; import { Align, + BoxSizing, Direction, Display, Edge, diff --git a/javascript/tests/generated/YGBorderTest.test.ts b/javascript/tests/generated/YGBorderTest.test.ts index 5e336847..ddbdd2aa 100644 --- a/javascript/tests/generated/YGBorderTest.test.ts +++ b/javascript/tests/generated/YGBorderTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<675d8bdccff33c46128330c9bd6c9b87>> + * @generated SignedSource<> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGBorderTest.html */ @@ -12,6 +12,7 @@ import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' import Yoga from 'yoga-layout'; import { Align, + BoxSizing, Direction, Display, Edge, diff --git a/javascript/tests/generated/YGBoxSizingTest.test.ts b/javascript/tests/generated/YGBoxSizingTest.test.ts new file mode 100644 index 00000000..55e61852 --- /dev/null +++ b/javascript/tests/generated/YGBoxSizingTest.test.ts @@ -0,0 +1,69 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/YGBoxSizingTest.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test.skip('box_sizing_content_box', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 5); + root.setPadding(Edge.Top, 5); + root.setPadding(Edge.Right, 5); + root.setPadding(Edge.Bottom, 5); + root.setBorder(Edge.Left, 10); + root.setBorder(Edge.Top, 10); + root.setBorder(Edge.Right, 10); + root.setBorder(Edge.Bottom, 10); + root.setWidth(100); + root.setHeight(100); + root.setBoxSizing(BoxSizing.ContentBox); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(130); + expect(root.getComputedHeight()).toBe(130); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(130); + expect(root.getComputedHeight()).toBe(130); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/YGDimensionTest.test.ts b/javascript/tests/generated/YGDimensionTest.test.ts index 76cd5716..39c140df 100644 --- a/javascript/tests/generated/YGDimensionTest.test.ts +++ b/javascript/tests/generated/YGDimensionTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<51018ace00a5b85422b92cec7acc9f4d>> + * @generated SignedSource<<719c8f3b9fea672881a47f593f4aabd0>> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGDimensionTest.html */ @@ -12,6 +12,7 @@ import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' import Yoga from 'yoga-layout'; import { Align, + BoxSizing, Direction, Display, Edge, diff --git a/javascript/tests/generated/YGDisplayTest.test.ts b/javascript/tests/generated/YGDisplayTest.test.ts index a35c7498..fa2f0b41 100644 --- a/javascript/tests/generated/YGDisplayTest.test.ts +++ b/javascript/tests/generated/YGDisplayTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<> + * @generated SignedSource<<1f15f9628f43eed206466695ec6e683c>> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGDisplayTest.html */ @@ -12,6 +12,7 @@ import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' import Yoga from 'yoga-layout'; import { Align, + BoxSizing, Direction, Display, Edge, diff --git a/javascript/tests/generated/YGFlexDirectionTest.test.ts b/javascript/tests/generated/YGFlexDirectionTest.test.ts index cbc5aa07..2999befc 100644 --- a/javascript/tests/generated/YGFlexDirectionTest.test.ts +++ b/javascript/tests/generated/YGFlexDirectionTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<5cc8e03bdba27ff2003afbde3b5ed0b7>> + * @generated SignedSource<<285a0c9dd4b646e7b1af77658fc41d99>> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGFlexDirectionTest.html */ @@ -12,6 +12,7 @@ import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' import Yoga from 'yoga-layout'; import { Align, + BoxSizing, Direction, Display, Edge, diff --git a/javascript/tests/generated/YGFlexTest.test.ts b/javascript/tests/generated/YGFlexTest.test.ts index 65c95258..6eee8e86 100644 --- a/javascript/tests/generated/YGFlexTest.test.ts +++ b/javascript/tests/generated/YGFlexTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<0b2282a5a0b35e95e7e27417e6b25ff6>> + * @generated SignedSource<<60e19ea0b6b108cd6b0d4062c0b0316d>> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGFlexTest.html */ @@ -12,6 +12,7 @@ import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' import Yoga from 'yoga-layout'; import { Align, + BoxSizing, Direction, Display, Edge, diff --git a/javascript/tests/generated/YGFlexWrapTest.test.ts b/javascript/tests/generated/YGFlexWrapTest.test.ts index 85994ff7..28ee4cee 100644 --- a/javascript/tests/generated/YGFlexWrapTest.test.ts +++ b/javascript/tests/generated/YGFlexWrapTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<11f5ca827ba97151a67ab3f05cf48f53>> + * @generated SignedSource<<5c4e3faf7c401d359b341c41a3055313>> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGFlexWrapTest.html */ @@ -12,6 +12,7 @@ import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' import Yoga from 'yoga-layout'; import { Align, + BoxSizing, Direction, Display, Edge, diff --git a/javascript/tests/generated/YGGapTest.test.ts b/javascript/tests/generated/YGGapTest.test.ts index 54bb085f..d38f592e 100644 --- a/javascript/tests/generated/YGGapTest.test.ts +++ b/javascript/tests/generated/YGGapTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<> + * @generated SignedSource<<3fad56933a314f0a81b6ed504040ffae>> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGGapTest.html */ @@ -12,6 +12,7 @@ import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' import Yoga from 'yoga-layout'; import { Align, + BoxSizing, Direction, Display, Edge, diff --git a/javascript/tests/generated/YGIntrinsicSizeTest.test.ts b/javascript/tests/generated/YGIntrinsicSizeTest.test.ts index d272ceff..b0f27c05 100644 --- a/javascript/tests/generated/YGIntrinsicSizeTest.test.ts +++ b/javascript/tests/generated/YGIntrinsicSizeTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<63249d156daefb8d7d536b57c7d8cb70>> + * @generated SignedSource<> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGIntrinsicSizeTest.html */ @@ -12,6 +12,7 @@ import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' import Yoga from 'yoga-layout'; import { Align, + BoxSizing, Direction, Display, Edge, diff --git a/javascript/tests/generated/YGJustifyContentTest.test.ts b/javascript/tests/generated/YGJustifyContentTest.test.ts index 22f8d3e9..97869b22 100644 --- a/javascript/tests/generated/YGJustifyContentTest.test.ts +++ b/javascript/tests/generated/YGJustifyContentTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<> + * @generated SignedSource<<4d367d399575872c385f254588d91fb5>> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGJustifyContentTest.html */ @@ -12,6 +12,7 @@ import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' import Yoga from 'yoga-layout'; import { Align, + BoxSizing, Direction, Display, Edge, diff --git a/javascript/tests/generated/YGMarginTest.test.ts b/javascript/tests/generated/YGMarginTest.test.ts index d5d655fd..8046de55 100644 --- a/javascript/tests/generated/YGMarginTest.test.ts +++ b/javascript/tests/generated/YGMarginTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<910ea7258ef002557289f475dc74f3dc>> + * @generated SignedSource<<3a4aaa192f950239104218a9666654c1>> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGMarginTest.html */ @@ -12,6 +12,7 @@ import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' import Yoga from 'yoga-layout'; import { Align, + BoxSizing, Direction, Display, Edge, diff --git a/javascript/tests/generated/YGMinMaxDimensionTest.test.ts b/javascript/tests/generated/YGMinMaxDimensionTest.test.ts index 936ee3c4..dfe3773f 100644 --- a/javascript/tests/generated/YGMinMaxDimensionTest.test.ts +++ b/javascript/tests/generated/YGMinMaxDimensionTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<> + * @generated SignedSource<<1bd782301afbab34ed3c9a296c3ecaa6>> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGMinMaxDimensionTest.html */ @@ -12,6 +12,7 @@ import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' import Yoga from 'yoga-layout'; import { Align, + BoxSizing, Direction, Display, Edge, diff --git a/javascript/tests/generated/YGPaddingTest.test.ts b/javascript/tests/generated/YGPaddingTest.test.ts index 7262148e..474a8082 100644 --- a/javascript/tests/generated/YGPaddingTest.test.ts +++ b/javascript/tests/generated/YGPaddingTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<2e4b35c2408710c0aabaa82e43e157cb>> + * @generated SignedSource<<07e65137c3055db0090d46067ec69d5e>> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGPaddingTest.html */ @@ -12,6 +12,7 @@ import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' import Yoga from 'yoga-layout'; import { Align, + BoxSizing, Direction, Display, Edge, diff --git a/javascript/tests/generated/YGPercentageTest.test.ts b/javascript/tests/generated/YGPercentageTest.test.ts index 587b93b3..4f95fb28 100644 --- a/javascript/tests/generated/YGPercentageTest.test.ts +++ b/javascript/tests/generated/YGPercentageTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<6af8e434b1131c83b7feb6ff04a2dffd>> + * @generated SignedSource<<091fb5c6d9004e40211bba58ac19d686>> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGPercentageTest.html */ @@ -12,6 +12,7 @@ import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' import Yoga from 'yoga-layout'; import { Align, + BoxSizing, Direction, Display, Edge, diff --git a/javascript/tests/generated/YGRoundingTest.test.ts b/javascript/tests/generated/YGRoundingTest.test.ts index fa18597d..ca653f13 100644 --- a/javascript/tests/generated/YGRoundingTest.test.ts +++ b/javascript/tests/generated/YGRoundingTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<203f3aa8922cb3fa03e7946f91a6ed2d>> + * @generated SignedSource<<8119d2703019b25513720167cb4dea4e>> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGRoundingTest.html */ @@ -12,6 +12,7 @@ import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' import Yoga from 'yoga-layout'; import { Align, + BoxSizing, Direction, Display, Edge, diff --git a/javascript/tests/generated/YGSizeOverflowTest.test.ts b/javascript/tests/generated/YGSizeOverflowTest.test.ts index c11b2684..325dd26d 100644 --- a/javascript/tests/generated/YGSizeOverflowTest.test.ts +++ b/javascript/tests/generated/YGSizeOverflowTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<> + * @generated SignedSource<> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGSizeOverflowTest.html */ @@ -12,6 +12,7 @@ import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' import Yoga from 'yoga-layout'; import { Align, + BoxSizing, Direction, Display, Edge, diff --git a/javascript/tests/generated/YGStaticPositionTest.test.ts b/javascript/tests/generated/YGStaticPositionTest.test.ts index 3c1e4851..0c2bd373 100644 --- a/javascript/tests/generated/YGStaticPositionTest.test.ts +++ b/javascript/tests/generated/YGStaticPositionTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<> + * @generated SignedSource<> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGStaticPositionTest.html */ @@ -12,6 +12,7 @@ import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' import Yoga from 'yoga-layout'; import { Align, + BoxSizing, Direction, Display, Edge, diff --git a/tests/generated/YGBoxSizingTest.cpp b/tests/generated/YGBoxSizingTest.cpp new file mode 100644 index 00000000..70206f67 --- /dev/null +++ b/tests/generated/YGBoxSizingTest.cpp @@ -0,0 +1,51 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * clang-format off + * @generated SignedSource<<6a7f059e2eb63c8cd443dcddf18e4ed6>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/YGBoxSizingTest.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, box_sizing_content_box) { + GTEST_SKIP(); + + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root, YGEdgeLeft, 5); + YGNodeStyleSetPadding(root, YGEdgeTop, 5); + YGNodeStyleSetPadding(root, YGEdgeRight, 5); + YGNodeStyleSetPadding(root, YGEdgeBottom, 5); + YGNodeStyleSetBorder(root, YGEdgeLeft, 10); + YGNodeStyleSetBorder(root, YGEdgeTop, 10); + YGNodeStyleSetBorder(root, YGEdgeRight, 10); + YGNodeStyleSetBorder(root, YGEdgeBottom, 10); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetBoxSizing(root, YGBoxSizingContentBox); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(130, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(130, YGNodeLayoutGetHeight(root)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(130, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(130, YGNodeLayoutGetHeight(root)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +}