Skip to content

Commit 990ec92

Browse files
joevilchesfacebook-github-bot
authored andcommitted
Add default test for box sizing (#1716)
Summary: X-link: facebook/react-native#46800 Pull Request resolved: #1716 Had a mini heart attack thinking I set the default to content box. Wrote this to double check and it passed. Might as well check it in Technically the default to BoxSizing.h is ContentBox, but in the style we override that. Regardless I switched that around so border box was the default. Changelog: [Internal] Reviewed By: NickGerleman Differential Revision: D63802722 fbshipit-source-id: 49ed29657c964bc12a2bf70988061ab4599267ec
1 parent 3351e8e commit 990ec92

File tree

7 files changed

+24
-13
lines changed

7 files changed

+24
-13
lines changed

enums.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"PositionType": ["Static", "Relative", "Absolute"],
3434
"Display": ["Flex", "None"],
3535
"Wrap": ["NoWrap", "Wrap", "WrapReverse"],
36-
"BoxSizing": ["ContentBox", "BorderBox"],
36+
"BoxSizing": ["BorderBox", "ContentBox"],
3737
"MeasureMode": ["Undefined", "Exactly", "AtMost"],
3838
"Dimension": ["Width", "Height"],
3939
"Edge": [

java/com/facebook/yoga/YogaBoxSizing.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
package com.facebook.yoga;
1111

1212
public enum YogaBoxSizing {
13-
CONTENT_BOX(0),
14-
BORDER_BOX(1);
13+
BORDER_BOX(0),
14+
CONTENT_BOX(1);
1515

1616
private final int mIntValue;
1717

@@ -25,8 +25,8 @@ public int intValue() {
2525

2626
public static YogaBoxSizing fromInt(int value) {
2727
switch (value) {
28-
case 0: return CONTENT_BOX;
29-
case 1: return BORDER_BOX;
28+
case 0: return BORDER_BOX;
29+
case 1: return CONTENT_BOX;
3030
default: throw new IllegalArgumentException("Unknown enum value: " + value);
3131
}
3232
}

javascript/src/generated/YGEnums.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ export enum Align {
2020
}
2121

2222
export enum BoxSizing {
23-
ContentBox = 0,
24-
BorderBox = 1,
23+
BorderBox = 0,
24+
ContentBox = 1,
2525
}
2626

2727
export enum Dimension {
@@ -142,8 +142,8 @@ const constants = {
142142
ALIGN_SPACE_BETWEEN: Align.SpaceBetween,
143143
ALIGN_SPACE_AROUND: Align.SpaceAround,
144144
ALIGN_SPACE_EVENLY: Align.SpaceEvenly,
145-
BOX_SIZING_CONTENT_BOX: BoxSizing.ContentBox,
146145
BOX_SIZING_BORDER_BOX: BoxSizing.BorderBox,
146+
BOX_SIZING_CONTENT_BOX: BoxSizing.ContentBox,
147147
DIMENSION_WIDTH: Dimension.Width,
148148
DIMENSION_HEIGHT: Dimension.Height,
149149
DIRECTION_INHERIT: Direction.Inherit,

tests/YGDefaultValuesTest.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,3 +162,14 @@ TEST(YogaTest, assert_legacy_stretch_behaviour) {
162162

163163
YGConfigFree(config);
164164
}
165+
166+
TEST(YogaTest, assert_box_sizing_border_box) {
167+
YGConfig* config = YGConfigNew();
168+
YGNodeRef root = YGNodeNewWithConfig(config);
169+
170+
ASSERT_EQ(YGBoxSizingBorderBox, YGNodeStyleGetBoxSizing(root));
171+
172+
YGNodeFreeRecursive(root);
173+
174+
YGConfigFree(config);
175+
}

yoga/YGEnums.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ const char* YGAlignToString(const YGAlign value) {
3535

3636
const char* YGBoxSizingToString(const YGBoxSizing value) {
3737
switch (value) {
38-
case YGBoxSizingContentBox:
39-
return "content-box";
4038
case YGBoxSizingBorderBox:
4139
return "border-box";
40+
case YGBoxSizingContentBox:
41+
return "content-box";
4242
}
4343
return "unknown";
4444
}

yoga/YGEnums.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ YG_ENUM_DECL(
2626

2727
YG_ENUM_DECL(
2828
YGBoxSizing,
29-
YGBoxSizingContentBox,
30-
YGBoxSizingBorderBox)
29+
YGBoxSizingBorderBox,
30+
YGBoxSizingContentBox)
3131

3232
YG_ENUM_DECL(
3333
YGDimension,

yoga/enums/BoxSizing.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
namespace facebook::yoga {
1717

1818
enum class BoxSizing : uint8_t {
19-
ContentBox = YGBoxSizingContentBox,
2019
BorderBox = YGBoxSizingBorderBox,
20+
ContentBox = YGBoxSizingContentBox,
2121
};
2222

2323
template <>

0 commit comments

Comments
 (0)