Add default test for box sizing #1716
2
enums.py
2
enums.py
@@ -33,7 +33,7 @@ ENUMS = {
|
|||||||
"PositionType": ["Static", "Relative", "Absolute"],
|
"PositionType": ["Static", "Relative", "Absolute"],
|
||||||
"Display": ["Flex", "None"],
|
"Display": ["Flex", "None"],
|
||||||
"Wrap": ["NoWrap", "Wrap", "WrapReverse"],
|
"Wrap": ["NoWrap", "Wrap", "WrapReverse"],
|
||||||
"BoxSizing": ["ContentBox", "BorderBox"],
|
"BoxSizing": ["BorderBox", "ContentBox"],
|
||||||
"MeasureMode": ["Undefined", "Exactly", "AtMost"],
|
"MeasureMode": ["Undefined", "Exactly", "AtMost"],
|
||||||
"Dimension": ["Width", "Height"],
|
"Dimension": ["Width", "Height"],
|
||||||
"Edge": [
|
"Edge": [
|
||||||
|
@@ -10,8 +10,8 @@
|
|||||||
package com.facebook.yoga;
|
package com.facebook.yoga;
|
||||||
|
|
||||||
public enum YogaBoxSizing {
|
public enum YogaBoxSizing {
|
||||||
CONTENT_BOX(0),
|
BORDER_BOX(0),
|
||||||
BORDER_BOX(1);
|
CONTENT_BOX(1);
|
||||||
|
|
||||||
private final int mIntValue;
|
private final int mIntValue;
|
||||||
|
|
||||||
@@ -25,8 +25,8 @@ public enum YogaBoxSizing {
|
|||||||
|
|
||||||
public static YogaBoxSizing fromInt(int value) {
|
public static YogaBoxSizing fromInt(int value) {
|
||||||
switch (value) {
|
switch (value) {
|
||||||
case 0: return CONTENT_BOX;
|
case 0: return BORDER_BOX;
|
||||||
case 1: return BORDER_BOX;
|
case 1: return CONTENT_BOX;
|
||||||
default: throw new IllegalArgumentException("Unknown enum value: " + value);
|
default: throw new IllegalArgumentException("Unknown enum value: " + value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -20,8 +20,8 @@ export enum Align {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export enum BoxSizing {
|
export enum BoxSizing {
|
||||||
ContentBox = 0,
|
BorderBox = 0,
|
||||||
BorderBox = 1,
|
ContentBox = 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum Dimension {
|
export enum Dimension {
|
||||||
@@ -142,8 +142,8 @@ const constants = {
|
|||||||
ALIGN_SPACE_BETWEEN: Align.SpaceBetween,
|
ALIGN_SPACE_BETWEEN: Align.SpaceBetween,
|
||||||
ALIGN_SPACE_AROUND: Align.SpaceAround,
|
ALIGN_SPACE_AROUND: Align.SpaceAround,
|
||||||
ALIGN_SPACE_EVENLY: Align.SpaceEvenly,
|
ALIGN_SPACE_EVENLY: Align.SpaceEvenly,
|
||||||
BOX_SIZING_CONTENT_BOX: BoxSizing.ContentBox,
|
|
||||||
BOX_SIZING_BORDER_BOX: BoxSizing.BorderBox,
|
BOX_SIZING_BORDER_BOX: BoxSizing.BorderBox,
|
||||||
|
BOX_SIZING_CONTENT_BOX: BoxSizing.ContentBox,
|
||||||
DIMENSION_WIDTH: Dimension.Width,
|
DIMENSION_WIDTH: Dimension.Width,
|
||||||
DIMENSION_HEIGHT: Dimension.Height,
|
DIMENSION_HEIGHT: Dimension.Height,
|
||||||
DIRECTION_INHERIT: Direction.Inherit,
|
DIRECTION_INHERIT: Direction.Inherit,
|
||||||
|
@@ -162,3 +162,14 @@ TEST(YogaTest, assert_legacy_stretch_behaviour) {
|
|||||||
|
|
||||||
YGConfigFree(config);
|
YGConfigFree(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(YogaTest, assert_box_sizing_border_box) {
|
||||||
|
YGConfig* config = YGConfigNew();
|
||||||
|
YGNodeRef root = YGNodeNewWithConfig(config);
|
||||||
|
|
||||||
|
ASSERT_EQ(YGBoxSizingBorderBox, YGNodeStyleGetBoxSizing(root));
|
||||||
|
|
||||||
|
YGNodeFreeRecursive(root);
|
||||||
|
|
||||||
|
YGConfigFree(config);
|
||||||
|
}
|
||||||
|
@@ -35,10 +35,10 @@ const char* YGAlignToString(const YGAlign value) {
|
|||||||
|
|
||||||
const char* YGBoxSizingToString(const YGBoxSizing value) {
|
const char* YGBoxSizingToString(const YGBoxSizing value) {
|
||||||
switch (value) {
|
switch (value) {
|
||||||
case YGBoxSizingContentBox:
|
|
||||||
return "content-box";
|
|
||||||
case YGBoxSizingBorderBox:
|
case YGBoxSizingBorderBox:
|
||||||
return "border-box";
|
return "border-box";
|
||||||
|
case YGBoxSizingContentBox:
|
||||||
|
return "content-box";
|
||||||
}
|
}
|
||||||
return "unknown";
|
return "unknown";
|
||||||
}
|
}
|
||||||
|
@@ -26,8 +26,8 @@ YG_ENUM_DECL(
|
|||||||
|
|
||||||
YG_ENUM_DECL(
|
YG_ENUM_DECL(
|
||||||
YGBoxSizing,
|
YGBoxSizing,
|
||||||
YGBoxSizingContentBox,
|
YGBoxSizingBorderBox,
|
||||||
YGBoxSizingBorderBox)
|
YGBoxSizingContentBox)
|
||||||
|
|
||||||
YG_ENUM_DECL(
|
YG_ENUM_DECL(
|
||||||
YGDimension,
|
YGDimension,
|
||||||
|
@@ -16,8 +16,8 @@
|
|||||||
namespace facebook::yoga {
|
namespace facebook::yoga {
|
||||||
|
|
||||||
enum class BoxSizing : uint8_t {
|
enum class BoxSizing : uint8_t {
|
||||||
ContentBox = YGBoxSizingContentBox,
|
|
||||||
BorderBox = YGBoxSizingBorderBox,
|
BorderBox = YGBoxSizingBorderBox,
|
||||||
|
ContentBox = YGBoxSizingContentBox,
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
|
Reference in New Issue
Block a user