diff --git a/CSSLayout/CSSLayout.c b/CSSLayout/CSSLayout.c index 84c51e79..967647b2 100644 --- a/CSSLayout/CSSLayout.c +++ b/CSSLayout/CSSLayout.c @@ -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); diff --git a/CSSLayout/CSSLayout.h b/CSSLayout/CSSLayout.h index 37c24d93..fd18f276 100644 --- a/CSSLayout/CSSLayout.h +++ b/CSSLayout/CSSLayout.h @@ -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); diff --git a/benchmarks/CSSBenchmark.c b/benchmarks/CSSBenchmark.c index d47f9ff8..b5bff56e 100644 --- a/benchmarks/CSSBenchmark.c +++ b/benchmarks/CSSBenchmark.c @@ -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); }); }); diff --git a/gentest/gentest.js b/gentest/gentest.js index fd666964..4f01a627 100755 --- a/gentest/gentest.js +++ b/gentest/gentest.js @@ -93,6 +93,7 @@ function printTest(LTRContainer, RTLContainer, genericContainer) { return curr + '\n ' + prev; })); + lines.push('\n CSSNodeFreeRecursive(root);') lines.push('}'); lines.push(''); } diff --git a/tests/CSSLayoutAbsolutePositionTest.cpp b/tests/CSSLayoutAbsolutePositionTest.cpp index 4ac37a9f..d817b6ff 100644 --- a/tests/CSSLayoutAbsolutePositionTest.cpp +++ b/tests/CSSLayoutAbsolutePositionTest.cpp @@ -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); } diff --git a/tests/CSSLayoutAlignContentTest.cpp b/tests/CSSLayoutAlignContentTest.cpp index 8a3674d2..622a0ead 100644 --- a/tests/CSSLayoutAlignContentTest.cpp +++ b/tests/CSSLayoutAlignContentTest.cpp @@ -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); } diff --git a/tests/CSSLayoutAlignItemsTest.cpp b/tests/CSSLayoutAlignItemsTest.cpp index 8e4a8789..9a9ca6cc 100644 --- a/tests/CSSLayoutAlignItemsTest.cpp +++ b/tests/CSSLayoutAlignItemsTest.cpp @@ -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); } diff --git a/tests/CSSLayoutAlignSelfTest.cpp b/tests/CSSLayoutAlignSelfTest.cpp index 1262fc76..7392fc8a 100644 --- a/tests/CSSLayoutAlignSelfTest.cpp +++ b/tests/CSSLayoutAlignSelfTest.cpp @@ -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); } diff --git a/tests/CSSLayoutBorderTest.cpp b/tests/CSSLayoutBorderTest.cpp index 871b01bd..3881708d 100644 --- a/tests/CSSLayoutBorderTest.cpp +++ b/tests/CSSLayoutBorderTest.cpp @@ -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); } diff --git a/tests/CSSLayoutDirtyMarkingTest.cpp b/tests/CSSLayoutDirtyMarkingTest.cpp index d460718a..50d86c7c 100644 --- a/tests/CSSLayoutDirtyMarkingTest.cpp +++ b/tests/CSSLayoutDirtyMarkingTest.cpp @@ -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); } diff --git a/tests/CSSLayoutEdgeTest.cpp b/tests/CSSLayoutEdgeTest.cpp index c729c71e..09c718ed 100644 --- a/tests/CSSLayoutEdgeTest.cpp +++ b/tests/CSSLayoutEdgeTest.cpp @@ -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); } diff --git a/tests/CSSLayoutFlexDirectionTest.cpp b/tests/CSSLayoutFlexDirectionTest.cpp index 9f23ae1b..c1226c26 100644 --- a/tests/CSSLayoutFlexDirectionTest.cpp +++ b/tests/CSSLayoutFlexDirectionTest.cpp @@ -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); } diff --git a/tests/CSSLayoutFlexTest.cpp b/tests/CSSLayoutFlexTest.cpp index 488de4b9..402d5143 100644 --- a/tests/CSSLayoutFlexTest.cpp +++ b/tests/CSSLayoutFlexTest.cpp @@ -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); } diff --git a/tests/CSSLayoutFlexWrapTest.cpp b/tests/CSSLayoutFlexWrapTest.cpp index 302b137c..42dece2f 100644 --- a/tests/CSSLayoutFlexWrapTest.cpp +++ b/tests/CSSLayoutFlexWrapTest.cpp @@ -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); } diff --git a/tests/CSSLayoutJustifyContentTest.cpp b/tests/CSSLayoutJustifyContentTest.cpp index 01f5b968..dde60e7d 100644 --- a/tests/CSSLayoutJustifyContentTest.cpp +++ b/tests/CSSLayoutJustifyContentTest.cpp @@ -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); } diff --git a/tests/CSSLayoutMarginTest.cpp b/tests/CSSLayoutMarginTest.cpp index d7c057f1..1a504390 100644 --- a/tests/CSSLayoutMarginTest.cpp +++ b/tests/CSSLayoutMarginTest.cpp @@ -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); } diff --git a/tests/CSSLayoutMeasureCacheTest.cpp b/tests/CSSLayoutMeasureCacheTest.cpp index aee2d9cc..4261fc33 100644 --- a/tests/CSSLayoutMeasureCacheTest.cpp +++ b/tests/CSSLayoutMeasureCacheTest.cpp @@ -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); } diff --git a/tests/CSSLayoutMeasureModeTest.cpp b/tests/CSSLayoutMeasureModeTest.cpp index 27fd4240..979a9444 100644 --- a/tests/CSSLayoutMeasureModeTest.cpp +++ b/tests/CSSLayoutMeasureModeTest.cpp @@ -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); +} diff --git a/tests/CSSLayoutMinMaxDimensionTest.cpp b/tests/CSSLayoutMinMaxDimensionTest.cpp index b81df8f8..4bcb4911 100644 --- a/tests/CSSLayoutMinMaxDimensionTest.cpp +++ b/tests/CSSLayoutMinMaxDimensionTest.cpp @@ -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); } diff --git a/tests/CSSLayoutPaddingTest.cpp b/tests/CSSLayoutPaddingTest.cpp index 55faa669..9ec3e7db 100644 --- a/tests/CSSLayoutPaddingTest.cpp +++ b/tests/CSSLayoutPaddingTest.cpp @@ -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); }