Skip to content

Commit

Permalink
Revamp tests for row reverse + padding after fix
Browse files Browse the repository at this point in the history
Summary: no longer skip passing tests + add errata tests

Reviewed By: NickGerleman

Differential Revision: D50282417

fbshipit-source-id: 515600111c1ad7b15e40cfe5a3894e40c241c559
  • Loading branch information
joevilches authored and facebook-github-bot committed Oct 18, 2023
1 parent 7502595 commit 2e2c124
Show file tree
Hide file tree
Showing 5 changed files with 146 additions and 10 deletions.
4 changes: 2 additions & 2 deletions gentest/fixtures/YGFlexDirectionTest.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
<div style="width: 10px;"></div>
</div>

<div id="flex_direction_row_reverse_padding_start" data-disabled="true" style="height: 100px; width: 100px; flex-direction: row-reverse; padding-start: 100px;">
<div id="flex_direction_row_reverse_padding_start" style="height: 100px; width: 100px; flex-direction: row-reverse; padding-start: 100px;">
<div style="width: 10px;"></div>
<div style="width: 10px;"></div>
<div style="width: 10px;"></div>
Expand All @@ -89,7 +89,7 @@
<div style="width: 10px;"></div>
</div>

<div id="flex_direction_row_reverse_padding_end" data-disabled="true" style="height: 100px; width: 100px; flex-direction: row-reverse; padding-end: 100px;">
<div id="flex_direction_row_reverse_padding_end" style="height: 100px; width: 100px; flex-direction: row-reverse; padding-end: 100px;">
<div style="width: 10px;"></div>
<div style="width: 10px;"></div>
<div style="width: 10px;"></div>
Expand Down
2 changes: 0 additions & 2 deletions java/tests/com/facebook/yoga/YGFlexDirectionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,6 @@ public void test_flex_direction_row_reverse_padding_left() {
}

@Test
@Ignore
public void test_flex_direction_row_reverse_padding_start() {
YogaConfig config = YogaConfigFactory.create();
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true);
Expand Down Expand Up @@ -1052,7 +1051,6 @@ public void test_flex_direction_row_reverse_padding_right() {
}

@Test
@Ignore
public void test_flex_direction_row_reverse_padding_end() {
YogaConfig config = YogaConfigFactory.create();
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true);
Expand Down
4 changes: 2 additions & 2 deletions javascript/tests/generated/YGFlexDirectionTest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,7 @@ test('flex_direction_row_reverse_padding_left', () => {
config.free();
}
});
test.skip('flex_direction_row_reverse_padding_start', () => {
test('flex_direction_row_reverse_padding_start', () => {
const config = Yoga.Config.create();
let root;

Expand Down Expand Up @@ -1140,7 +1140,7 @@ test('flex_direction_row_reverse_padding_right', () => {
config.free();
}
});
test.skip('flex_direction_row_reverse_padding_end', () => {
test('flex_direction_row_reverse_padding_end', () => {
const config = Yoga.Config.create();
let root;

Expand Down
142 changes: 142 additions & 0 deletions tests/YGFlexDirectionErrataTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,3 +293,145 @@ TEST(YogaTest, flex_direction_row_reverse_border_end_errata) {

YGConfigFree(config);
}

TEST(YogaTest, flex_direction_row_reverse_padding_start_errata) {
const YGConfigRef config = YGConfigNew();
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true);
YGConfigSetErrata(config, YGErrata::YGErrataStartingEndingEdgeFromFlexDirection);

const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRowReverse);
YGNodeStyleSetPadding(root, YGEdgeStart, 100);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);

const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);

const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);

const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
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(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));

ASSERT_FLOAT_EQ(-10, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));

ASSERT_FLOAT_EQ(-20, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1));

ASSERT_FLOAT_EQ(-30, YGNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2));

YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);

ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));

ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));

ASSERT_FLOAT_EQ(110, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1));

ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2));

YGNodeFreeRecursive(root);

YGConfigFree(config);
}

TEST(YogaTest, flex_direction_row_reverse_padding_end_errata) {
const YGConfigRef config = YGConfigNew();
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true);
YGConfigSetErrata(config, YGErrata::YGErrataStartingEndingEdgeFromFlexDirection);

const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRowReverse);
YGNodeStyleSetPadding(root, YGEdgeEnd, 100);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);

const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);

const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);

const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
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(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));

ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));

ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1));

ASSERT_FLOAT_EQ(70, YGNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2));

YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);

ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, 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(100, 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(100, 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(100, YGNodeLayoutGetHeight(root_child2));

YGNodeFreeRecursive(root);

YGConfigFree(config);
}
4 changes: 0 additions & 4 deletions tests/generated/YGFlexDirectionTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -912,8 +912,6 @@ TEST(YogaTest, flex_direction_row_reverse_padding_left) {
}

TEST(YogaTest, flex_direction_row_reverse_padding_start) {
GTEST_SKIP();

const YGConfigRef config = YGConfigNew();
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true);

Expand Down Expand Up @@ -1054,8 +1052,6 @@ TEST(YogaTest, flex_direction_row_reverse_padding_right) {
}

TEST(YogaTest, flex_direction_row_reverse_padding_end) {
GTEST_SKIP();

const YGConfigRef config = YGConfigNew();
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true);

Expand Down

0 comments on commit 2e2c124

Please sign in to comment.