diff --git a/java/tests/com/facebook/yoga/YogaNodeTest.java b/java/tests/com/facebook/yoga/YogaNodeTest.java index d6d2f742..8f894f3c 100644 --- a/java/tests/com/facebook/yoga/YogaNodeTest.java +++ b/java/tests/com/facebook/yoga/YogaNodeTest.java @@ -31,9 +31,9 @@ public class YogaNodeTest { @Test public void testInit() { - final int refCount = YogaNative.jni_YGNodeGetInstanceCount(); + TestUtil.startCountingNodes(); final YogaNode node = createNode(); - assertEquals(refCount + 1, YogaNative.jni_YGNodeGetInstanceCount()); + assertEquals(1, TestUtil.stopCountingNodes()); } @Test diff --git a/tests/YGLayoutDiffingTest.cpp b/tests/YGLayoutDiffingTest.cpp index 96361d16..378b8046 100644 --- a/tests/YGLayoutDiffingTest.cpp +++ b/tests/YGLayoutDiffingTest.cpp @@ -5,10 +5,15 @@ * file in the root directory of this source tree. */ #include +#include #include #include +using facebook::yoga::test::TestUtil; + TEST(YogaTest, assert_layout_trees_are_same) { + TestUtil::startCountingNodes(); + YGConfig* config = YGConfigNew(); YGConfigSetUseLegacyStretchBehaviour(config, true); const YGNodeRef root1 = YGNodeNewWithConfig(config); @@ -30,12 +35,12 @@ TEST(YogaTest, assert_layout_trees_are_same) { YGNodeInsertChild(root1_child0_child0, root1_child0_child0_child0, 0); const int32_t cal1_configInstanceCount = YGConfigGetInstanceCount(); - const int32_t cal1_nodeInstanceCount = YGNodeGetInstanceCount(); + const int32_t cal1_nodeInstanceCount = TestUtil::nodeCount(); YGNodeCalculateLayout(root1, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_EQ(YGConfigGetInstanceCount(), cal1_configInstanceCount); - ASSERT_EQ(YGNodeGetInstanceCount(), cal1_nodeInstanceCount); + ASSERT_EQ(TestUtil::nodeCount(), cal1_nodeInstanceCount); const YGNodeRef root2 = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root2, 500); @@ -56,12 +61,12 @@ TEST(YogaTest, assert_layout_trees_are_same) { YGNodeInsertChild(root2_child0_child0, root2_child0_child0_child0, 0); const int32_t cal2_configInstanceCount = YGConfigGetInstanceCount(); - const int32_t cal2_nodeInstanceCount = YGNodeGetInstanceCount(); + const int32_t cal2_nodeInstanceCount = TestUtil::nodeCount(); YGNodeCalculateLayout(root2, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_EQ(YGConfigGetInstanceCount(), cal2_configInstanceCount); - ASSERT_EQ(YGNodeGetInstanceCount(), cal2_nodeInstanceCount); + ASSERT_EQ(TestUtil::nodeCount(), cal2_nodeInstanceCount); ASSERT_TRUE(YGNodeLayoutGetDidUseLegacyFlag(root1)); ASSERT_TRUE(YGNodeLayoutGetDidUseLegacyFlag(root2)); @@ -70,12 +75,12 @@ TEST(YogaTest, assert_layout_trees_are_same) { YGNodeStyleSetAlignItems(root2, YGAlignFlexEnd); const int32_t cal3_configInstanceCount = YGConfigGetInstanceCount(); - const int32_t cal3_nodeInstanceCount = YGNodeGetInstanceCount(); + const int32_t cal3_nodeInstanceCount = TestUtil::nodeCount(); YGNodeCalculateLayout(root2, YGUndefined, YGUndefined, YGDirectionLTR); ASSERT_EQ(YGConfigGetInstanceCount(), cal3_configInstanceCount); - ASSERT_EQ(YGNodeGetInstanceCount(), cal3_nodeInstanceCount); + ASSERT_EQ(TestUtil::stopCountingNodes(), cal3_nodeInstanceCount); ASSERT_FALSE(root1->isLayoutTreeEqualToNode(*root2)); diff --git a/tests/YGPersistenceTest.cpp b/tests/YGPersistenceTest.cpp index 69bd59b1..fe704a62 100644 --- a/tests/YGPersistenceTest.cpp +++ b/tests/YGPersistenceTest.cpp @@ -5,9 +5,12 @@ * file in the root directory of this source tree. */ #include +#include #include #include +using facebook::yoga::test::TestUtil; + TEST(YogaTest, cloning_shared_root) { const YGConfigRef config = YGConfigNew(); @@ -220,7 +223,7 @@ TEST(YogaTest, cloning_two_levels) { } TEST(YogaTest, cloning_and_freeing) { - const int32_t initialInstanceCount = YGNodeGetInstanceCount(); + TestUtil::startCountingNodes(); const YGConfigRef config = YGConfigNew(); @@ -249,7 +252,7 @@ TEST(YogaTest, cloning_and_freeing) { YGConfigFree(config); - ASSERT_EQ(initialInstanceCount, YGNodeGetInstanceCount()); + ASSERT_EQ(0, TestUtil::stopCountingNodes()); } TEST(YogaTest, mixed_shared_and_owned_children) {