Free memory used in tests to enable use of valgrind

Summary: Its very usefull to be able to run valgrind on the tests and benchmarks. We were previously not freeing test memory so valgrind output was very messy.

Reviewed By: javache

Differential Revision: D3937493

fbshipit-source-id: 23c6970d7769b081575d39de583ba954fc65a397
This commit is contained in:
Emil Sjolander
2016-09-29 04:09:56 -07:00
committed by Facebook Github Bot
parent dbf3b11946
commit 1f300a58fb
20 changed files with 196 additions and 1 deletions

View File

@@ -142,6 +142,15 @@ void CSSNodeFree(const CSSNodeRef node) {
free(node);
}
void CSSNodeFreeRecursive(const CSSNodeRef root) {
while (CSSNodeChildCount(root) > 0) {
const CSSNodeRef child = CSSNodeGetChild(root, 0);
CSSNodeRemoveChild(root, child);
CSSNodeFreeRecursive(child);
}
CSSNodeFree(root);
}
void CSSNodeInit(const CSSNodeRef node) {
node->parent = NULL;
node->children = CSSNodeListNew(4);

View File

@@ -126,6 +126,7 @@ typedef void (*CSSPrintFunc)(void *context);
WIN_EXPORT CSSNodeRef CSSNodeNew();
WIN_EXPORT void CSSNodeInit(const CSSNodeRef node);
WIN_EXPORT void CSSNodeFree(const CSSNodeRef node);
WIN_EXPORT void CSSNodeFreeRecursive(const CSSNodeRef node);
WIN_EXPORT void CSSNodeInsertChild(const CSSNodeRef node, const CSSNodeRef child, const uint32_t index);
WIN_EXPORT void CSSNodeRemoveChild(const CSSNodeRef node, const CSSNodeRef child);

View File

@@ -42,6 +42,7 @@ CSS_BENCHMARKS({
}
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
CSSNodeFreeRecursive(root);
});
CSS_BENCHMARK("Align stretch in undefined axis", {
@@ -55,6 +56,7 @@ CSS_BENCHMARKS({
}
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
CSSNodeFreeRecursive(root);
});
CSS_BENCHMARK("Nested flex", {
@@ -75,6 +77,7 @@ CSS_BENCHMARKS({
}
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
CSSNodeFreeRecursive(root);
});
});

View File

@@ -93,6 +93,7 @@ function printTest(LTRContainer, RTLContainer, genericContainer) {
return curr + '\n ' + prev;
}));
lines.push('\n CSSNodeFreeRecursive(root);')
lines.push('}');
lines.push('');
}

View File

@@ -72,6 +72,8 @@ TEST(CSSLayoutTest, absolute_layout_width_height_start_top) {
ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, absolute_layout_width_height_end_bottom) {
@@ -109,6 +111,8 @@ TEST(CSSLayoutTest, absolute_layout_width_height_end_bottom) {
ASSERT_EQ(80, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, absolute_layout_start_top_end_bottom) {
@@ -146,6 +150,8 @@ TEST(CSSLayoutTest, absolute_layout_start_top_end_bottom) {
ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(80, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(80, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, absolute_layout_width_height_start_top_end_bottom) {
@@ -185,6 +191,8 @@ TEST(CSSLayoutTest, absolute_layout_width_height_start_top_end_bottom) {
ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent) {
@@ -235,4 +243,6 @@ TEST(CSSLayoutTest, do_not_clamp_height_of_absolute_node_to_height_of_its_overfl
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0_child0));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0_child0));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0_child0));
CSSNodeFreeRecursive(root);
}

View File

@@ -141,6 +141,8 @@ TEST(CSSLayoutTest, align_content_flex_start) {
ASSERT_EQ(40, CSSNodeLayoutGetTop(root_child4));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child4));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child4));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, align_content_flex_end) {
@@ -237,6 +239,8 @@ TEST(CSSLayoutTest, align_content_flex_end) {
ASSERT_EQ(40, CSSNodeLayoutGetTop(root_child4));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child4));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child4));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, align_content_center) {
@@ -333,6 +337,8 @@ TEST(CSSLayoutTest, align_content_center) {
ASSERT_EQ(40, CSSNodeLayoutGetTop(root_child4));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child4));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child4));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, align_content_stretch) {
@@ -424,4 +430,6 @@ TEST(CSSLayoutTest, align_content_stretch) {
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child4));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child4));
ASSERT_EQ(0, CSSNodeLayoutGetHeight(root_child4));
CSSNodeFreeRecursive(root);
}

View File

@@ -62,6 +62,8 @@ TEST(CSSLayoutTest, align_items_stretch) {
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, align_items_center) {
@@ -97,6 +99,8 @@ TEST(CSSLayoutTest, align_items_center) {
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, align_items_flex_start) {
@@ -132,6 +136,8 @@ TEST(CSSLayoutTest, align_items_flex_start) {
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, align_items_flex_end) {
@@ -167,4 +173,6 @@ TEST(CSSLayoutTest, align_items_flex_end) {
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
}

View File

@@ -64,6 +64,8 @@ TEST(CSSLayoutTest, align_self_center) {
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, align_self_flex_end) {
@@ -99,6 +101,8 @@ TEST(CSSLayoutTest, align_self_flex_end) {
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, align_self_flex_start) {
@@ -134,6 +138,8 @@ TEST(CSSLayoutTest, align_self_flex_start) {
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, align_self_flex_end_override_flex_start) {
@@ -170,4 +176,6 @@ TEST(CSSLayoutTest, align_self_flex_end_override_flex_start) {
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
}

View File

@@ -53,6 +53,8 @@ TEST(CSSLayoutTest, border_no_size) {
ASSERT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(20, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(20, CSSNodeLayoutGetHeight(root));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, border_container_match_child) {
@@ -89,6 +91,8 @@ TEST(CSSLayoutTest, border_container_match_child) {
ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, border_flex_child) {
@@ -127,6 +131,8 @@ TEST(CSSLayoutTest, border_flex_child) {
ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(80, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, border_stretch_child) {
@@ -164,6 +170,8 @@ TEST(CSSLayoutTest, border_stretch_child) {
ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(80, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, border_center_child) {
@@ -204,4 +212,6 @@ TEST(CSSLayoutTest, border_center_child) {
ASSERT_EQ(35, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
}

View File

@@ -39,6 +39,8 @@ TEST(CSSLayoutTest, dirty_propagation) {
EXPECT_FALSE(CSSNodeIsDirty(root_child0));
EXPECT_FALSE(CSSNodeIsDirty(root_child1));
EXPECT_FALSE(CSSNodeIsDirty(root));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, dirty_propagation_only_if_prop_changed) {
@@ -64,4 +66,6 @@ TEST(CSSLayoutTest, dirty_propagation_only_if_prop_changed) {
EXPECT_FALSE(CSSNodeIsDirty(root_child0));
EXPECT_FALSE(CSSNodeIsDirty(root_child1));
EXPECT_FALSE(CSSNodeIsDirty(root));
CSSNodeFreeRecursive(root);
}

View File

@@ -30,6 +30,8 @@ TEST(CSSLayoutTest, start_overrides) {
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL);
ASSERT_EQ(20, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetRight(root_child0));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, end_overrides) {
@@ -52,6 +54,8 @@ TEST(CSSLayoutTest, end_overrides) {
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL);
ASSERT_EQ(10, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(20, CSSNodeLayoutGetRight(root_child0));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, horizontal_overridden) {
@@ -69,6 +73,8 @@ TEST(CSSLayoutTest, horizontal_overridden) {
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(20, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetRight(root_child0));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, vertical_overridden) {
@@ -86,6 +92,8 @@ TEST(CSSLayoutTest, vertical_overridden) {
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(20, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetBottom(root_child0));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, horizontal_overrides_all) {
@@ -105,6 +113,8 @@ TEST(CSSLayoutTest, horizontal_overrides_all) {
ASSERT_EQ(20, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetRight(root_child0));
ASSERT_EQ(20, CSSNodeLayoutGetBottom(root_child0));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, vertical_overrides_all) {
@@ -124,6 +134,8 @@ TEST(CSSLayoutTest, vertical_overrides_all) {
ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(20, CSSNodeLayoutGetRight(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetBottom(root_child0));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, all_overridden) {
@@ -146,4 +158,6 @@ TEST(CSSLayoutTest, all_overridden) {
ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetRight(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetBottom(root_child0));
CSSNodeFreeRecursive(root);
}

View File

@@ -109,6 +109,8 @@ TEST(CSSLayoutTest, flex_direction_column_no_height) {
ASSERT_EQ(20, CSSNodeLayoutGetTop(root_child2));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, flex_direction_row_no_width) {
@@ -170,6 +172,8 @@ TEST(CSSLayoutTest, flex_direction_row_no_width) {
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child2));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, flex_direction_column) {
@@ -231,6 +235,8 @@ TEST(CSSLayoutTest, flex_direction_column) {
ASSERT_EQ(20, CSSNodeLayoutGetTop(root_child2));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, flex_direction_row) {
@@ -293,6 +299,8 @@ TEST(CSSLayoutTest, flex_direction_row) {
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child2));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, flex_direction_column_reverse) {
@@ -355,6 +363,8 @@ TEST(CSSLayoutTest, flex_direction_column_reverse) {
ASSERT_EQ(70, CSSNodeLayoutGetTop(root_child2));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, flex_direction_row_reverse) {
@@ -417,4 +427,6 @@ TEST(CSSLayoutTest, flex_direction_row_reverse) {
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child2));
CSSNodeFreeRecursive(root);
}

View File

@@ -81,6 +81,8 @@ TEST(CSSLayoutTest, flex_basis_flex_grow_column) {
ASSERT_EQ(75, CSSNodeLayoutGetTop(root_child1));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child1));
ASSERT_EQ(25, CSSNodeLayoutGetHeight(root_child1));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, flex_basis_flex_grow_row) {
@@ -130,6 +132,8 @@ TEST(CSSLayoutTest, flex_basis_flex_grow_row) {
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1));
ASSERT_EQ(25, CSSNodeLayoutGetWidth(root_child1));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child1));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, flex_basis_flex_shrink_column) {
@@ -178,6 +182,8 @@ TEST(CSSLayoutTest, flex_basis_flex_shrink_column) {
ASSERT_EQ(50, CSSNodeLayoutGetTop(root_child1));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child1));
ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child1));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, flex_basis_flex_shrink_row) {
@@ -227,4 +233,6 @@ TEST(CSSLayoutTest, flex_basis_flex_shrink_row) {
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child1));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child1));
CSSNodeFreeRecursive(root);
}

View File

@@ -125,6 +125,8 @@ TEST(CSSLayoutTest, wrap_column) {
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child3));
ASSERT_EQ(30, CSSNodeLayoutGetWidth(root_child3));
ASSERT_EQ(30, CSSNodeLayoutGetHeight(root_child3));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, wrap_row) {
@@ -205,6 +207,8 @@ TEST(CSSLayoutTest, wrap_row) {
ASSERT_EQ(30, CSSNodeLayoutGetTop(root_child3));
ASSERT_EQ(30, CSSNodeLayoutGetWidth(root_child3));
ASSERT_EQ(30, CSSNodeLayoutGetHeight(root_child3));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, wrap_row_align_items_flex_end) {
@@ -286,6 +290,8 @@ TEST(CSSLayoutTest, wrap_row_align_items_flex_end) {
ASSERT_EQ(30, CSSNodeLayoutGetTop(root_child3));
ASSERT_EQ(30, CSSNodeLayoutGetWidth(root_child3));
ASSERT_EQ(30, CSSNodeLayoutGetHeight(root_child3));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, wrap_row_align_items_center) {
@@ -367,4 +373,6 @@ TEST(CSSLayoutTest, wrap_row_align_items_center) {
ASSERT_EQ(30, CSSNodeLayoutGetTop(root_child3));
ASSERT_EQ(30, CSSNodeLayoutGetWidth(root_child3));
ASSERT_EQ(30, CSSNodeLayoutGetHeight(root_child3));
CSSNodeFreeRecursive(root);
}

View File

@@ -135,6 +135,8 @@ TEST(CSSLayoutTest, justify_content_row_flex_start) {
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(102, CSSNodeLayoutGetHeight(root_child2));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, justify_content_row_flex_end) {
@@ -198,6 +200,8 @@ TEST(CSSLayoutTest, justify_content_row_flex_end) {
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(102, CSSNodeLayoutGetHeight(root_child2));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, justify_content_row_center) {
@@ -261,6 +265,8 @@ TEST(CSSLayoutTest, justify_content_row_center) {
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(102, CSSNodeLayoutGetHeight(root_child2));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, justify_content_row_space_between) {
@@ -324,6 +330,8 @@ TEST(CSSLayoutTest, justify_content_row_space_between) {
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(102, CSSNodeLayoutGetHeight(root_child2));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, justify_content_row_space_around) {
@@ -387,6 +395,8 @@ TEST(CSSLayoutTest, justify_content_row_space_around) {
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(102, CSSNodeLayoutGetHeight(root_child2));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, justify_content_column_flex_start) {
@@ -447,6 +457,8 @@ TEST(CSSLayoutTest, justify_content_column_flex_start) {
ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child2));
ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, justify_content_column_flex_end) {
@@ -509,6 +521,8 @@ TEST(CSSLayoutTest, justify_content_column_flex_end) {
ASSERT_EQ(92, CSSNodeLayoutGetTop(root_child2));
ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, justify_content_column_center) {
@@ -571,6 +585,8 @@ TEST(CSSLayoutTest, justify_content_column_center) {
ASSERT_EQ(56, CSSNodeLayoutGetTop(root_child2));
ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, justify_content_column_space_between) {
@@ -633,6 +649,8 @@ TEST(CSSLayoutTest, justify_content_column_space_between) {
ASSERT_EQ(92, CSSNodeLayoutGetTop(root_child2));
ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, justify_content_column_space_around) {
@@ -695,4 +713,6 @@ TEST(CSSLayoutTest, justify_content_column_space_around) {
ASSERT_EQ(80, CSSNodeLayoutGetTop(root_child2));
ASSERT_EQ(102, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2));
CSSNodeFreeRecursive(root);
}

View File

@@ -90,6 +90,8 @@ TEST(CSSLayoutTest, margin_start) {
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, margin_top) {
@@ -124,6 +126,8 @@ TEST(CSSLayoutTest, margin_top) {
ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, margin_end) {
@@ -160,6 +164,8 @@ TEST(CSSLayoutTest, margin_end) {
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, margin_bottom) {
@@ -195,6 +201,8 @@ TEST(CSSLayoutTest, margin_bottom) {
ASSERT_EQ(80, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, margin_and_flex_row) {
@@ -230,6 +238,8 @@ TEST(CSSLayoutTest, margin_and_flex_row) {
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(90, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, margin_and_flex_column) {
@@ -264,6 +274,8 @@ TEST(CSSLayoutTest, margin_and_flex_column) {
ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(90, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, margin_and_stretch_row) {
@@ -299,6 +311,8 @@ TEST(CSSLayoutTest, margin_and_stretch_row) {
ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(90, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, margin_and_stretch_column) {
@@ -333,6 +347,8 @@ TEST(CSSLayoutTest, margin_and_stretch_column) {
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(90, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, margin_with_sibling_row) {
@@ -381,6 +397,8 @@ TEST(CSSLayoutTest, margin_with_sibling_row) {
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child1));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child1));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, margin_with_sibling_column) {
@@ -428,4 +446,6 @@ TEST(CSSLayoutTest, margin_with_sibling_column) {
ASSERT_EQ(50, CSSNodeLayoutGetTop(root_child1));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child1));
ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child1));
CSSNodeFreeRecursive(root);
}

View File

@@ -48,6 +48,8 @@ TEST(CSSLayoutTest, measure_once_single_flexible_child) {
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(1, measureCount);
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, dont_remeasure_text_node_height_change) {
@@ -77,4 +79,6 @@ TEST(CSSLayoutTest, dont_remeasure_text_node_height_change) {
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(1, measureCount);
CSSNodeFreeRecursive(root);
}

View File

@@ -63,6 +63,9 @@ TEST(CSSLayoutTest, exactly_measure_stretched_child_column) {
ASSERT_EQ(100, constraintList.constraints[0].width);
ASSERT_EQ(CSSMeasureModeExactly, constraintList.constraints[0].widthMode);
free(constraintList.constraints);
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, exactly_measure_stretched_child_row) {
@@ -87,6 +90,9 @@ TEST(CSSLayoutTest, exactly_measure_stretched_child_row) {
ASSERT_EQ(100, constraintList.constraints[0].height);
ASSERT_EQ(CSSMeasureModeExactly, constraintList.constraints[0].heightMode);
free(constraintList.constraints);
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, at_most_main_axis_column) {
@@ -110,6 +116,9 @@ TEST(CSSLayoutTest, at_most_main_axis_column) {
ASSERT_EQ(100, constraintList.constraints[0].height);
ASSERT_EQ(CSSMeasureModeAtMost, constraintList.constraints[0].heightMode);
free(constraintList.constraints);
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, at_most_cross_axis_column) {
@@ -134,6 +143,9 @@ TEST(CSSLayoutTest, at_most_cross_axis_column) {
ASSERT_EQ(100, constraintList.constraints[0].width);
ASSERT_EQ(CSSMeasureModeAtMost, constraintList.constraints[0].widthMode);
free(constraintList.constraints);
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, at_most_main_axis_row) {
@@ -158,6 +170,9 @@ TEST(CSSLayoutTest, at_most_main_axis_row) {
ASSERT_EQ(100, constraintList.constraints[0].width);
ASSERT_EQ(CSSMeasureModeAtMost, constraintList.constraints[0].widthMode);
free(constraintList.constraints);
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, at_most_cross_axis_row) {
@@ -183,6 +198,9 @@ TEST(CSSLayoutTest, at_most_cross_axis_row) {
ASSERT_EQ(100, constraintList.constraints[0].height);
ASSERT_EQ(CSSMeasureModeAtMost, constraintList.constraints[0].heightMode);
free(constraintList.constraints);
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, flex_child) {
@@ -209,6 +227,9 @@ TEST(CSSLayoutTest, flex_child) {
ASSERT_EQ(100, constraintList.constraints[1].height);
ASSERT_EQ(CSSMeasureModeExactly, constraintList.constraints[1].heightMode);
free(constraintList.constraints);
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, flex_child_with_flex_basis) {
@@ -233,6 +254,9 @@ TEST(CSSLayoutTest, flex_child_with_flex_basis) {
ASSERT_EQ(100, constraintList.constraints[0].height);
ASSERT_EQ(CSSMeasureModeExactly, constraintList.constraints[0].heightMode);
free(constraintList.constraints);
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, overflow_scroll_column) {
@@ -261,6 +285,9 @@ TEST(CSSLayoutTest, overflow_scroll_column) {
ASSERT_TRUE(CSSValueIsUndefined(constraintList.constraints[0].height));
ASSERT_EQ(CSSMeasureModeUndefined, constraintList.constraints[0].heightMode);
free(constraintList.constraints);
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, overflow_scroll_row) {
@@ -290,5 +317,7 @@ TEST(CSSLayoutTest, overflow_scroll_row) {
ASSERT_EQ(100, constraintList.constraints[0].height);
ASSERT_EQ(CSSMeasureModeAtMost, constraintList.constraints[0].heightMode);
}
free(constraintList.constraints);
CSSNodeFreeRecursive(root);
}

View File

@@ -65,6 +65,8 @@ TEST(CSSLayoutTest, max_width) {
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, max_height) {
@@ -100,6 +102,8 @@ TEST(CSSLayoutTest, max_height) {
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, min_height) {
@@ -148,6 +152,8 @@ TEST(CSSLayoutTest, min_height) {
ASSERT_EQ(80, CSSNodeLayoutGetTop(root_child1));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child1));
ASSERT_EQ(20, CSSNodeLayoutGetHeight(root_child1));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, min_width) {
@@ -197,4 +203,6 @@ TEST(CSSLayoutTest, min_width) {
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1));
ASSERT_EQ(20, CSSNodeLayoutGetWidth(root_child1));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child1));
CSSNodeFreeRecursive(root);
}

View File

@@ -53,6 +53,8 @@ TEST(CSSLayoutTest, padding_no_size) {
ASSERT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(20, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(20, CSSNodeLayoutGetHeight(root));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, padding_container_match_child) {
@@ -89,6 +91,8 @@ TEST(CSSLayoutTest, padding_container_match_child) {
ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, padding_flex_child) {
@@ -127,6 +131,8 @@ TEST(CSSLayoutTest, padding_flex_child) {
ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(80, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, padding_stretch_child) {
@@ -164,6 +170,8 @@ TEST(CSSLayoutTest, padding_stretch_child) {
ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(80, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, padding_center_child) {
@@ -204,4 +212,6 @@ TEST(CSSLayoutTest, padding_center_child) {
ASSERT_EQ(35, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
}