Index: tests/RTreeTest.cpp |
diff --git a/tests/RTreeTest.cpp b/tests/RTreeTest.cpp |
index 6296c4e7b84f5695924eea096fc5a0020187c9bb..666750b531639f5188bc788cd410f582cf882e77 100644 |
--- a/tests/RTreeTest.cpp |
+++ b/tests/RTreeTest.cpp |
@@ -68,7 +68,7 @@ static bool verify_query(SkIRect query, DataRect rects[], |
return found == expected; |
} |
-static void runQueries(skiatest::Reporter* reporter, SkMWCRandom& rand, DataRect rects[], |
+static void run_queries(skiatest::Reporter* reporter, SkMWCRandom& rand, DataRect rects[], |
SkRTree& tree) { |
for (size_t i = 0; i < NUM_QUERIES; ++i) { |
SkTDArray<void*> hits; |
@@ -78,11 +78,9 @@ static void runQueries(skiatest::Reporter* reporter, SkMWCRandom& rand, DataRect |
} |
} |
-static void TestRTree(skiatest::Reporter* reporter) { |
+static void rtree_test_main(SkRTree* rtree, skiatest::Reporter* reporter) { |
DataRect rects[NUM_RECTS]; |
SkMWCRandom rand; |
- SkRTree* rtree = SkRTree::Create(MIN_CHILDREN, MAX_CHILDREN); |
- SkAutoUnref au(rtree); |
REPORTER_ASSERT(reporter, NULL != rtree); |
int expectedDepthMin = -1; |
@@ -110,7 +108,7 @@ static void TestRTree(skiatest::Reporter* reporter) { |
rtree->insert(rects[i].data, rects[i].rect, true); |
} |
rtree->flushDeferredInserts(); |
- runQueries(reporter, rand, rects, *rtree); |
+ run_queries(reporter, rand, rects, *rtree); |
REPORTER_ASSERT(reporter, NUM_RECTS == rtree->getCount()); |
REPORTER_ASSERT(reporter, expectedDepthMin <= rtree->getDepth() && |
expectedDepthMax >= rtree->getDepth()); |
@@ -121,7 +119,7 @@ static void TestRTree(skiatest::Reporter* reporter) { |
for (int i = 0; i < NUM_RECTS; ++i) { |
rtree->insert(rects[i].data, rects[i].rect); |
} |
- runQueries(reporter, rand, rects, *rtree); |
+ run_queries(reporter, rand, rects, *rtree); |
REPORTER_ASSERT(reporter, NUM_RECTS == rtree->getCount()); |
REPORTER_ASSERT(reporter, expectedDepthMin <= rtree->getDepth() && |
expectedDepthMax >= rtree->getDepth()); |
@@ -132,7 +130,7 @@ static void TestRTree(skiatest::Reporter* reporter) { |
for (int i = NUM_RECTS - 1; i >= 0; --i) { |
rtree->insert(rects[i].data, rects[i].rect); |
} |
- runQueries(reporter, rand, rects, *rtree); |
+ run_queries(reporter, rand, rects, *rtree); |
REPORTER_ASSERT(reporter, NUM_RECTS == rtree->getCount()); |
REPORTER_ASSERT(reporter, expectedDepthMin <= rtree->getDepth() && |
expectedDepthMax >= rtree->getDepth()); |
@@ -141,5 +139,17 @@ static void TestRTree(skiatest::Reporter* reporter) { |
} |
} |
+static void test_rtree(skiatest::Reporter* reporter) { |
+ SkRTree* rtree = SkRTree::Create(MIN_CHILDREN, MAX_CHILDREN); |
+ SkAutoUnref au(rtree); |
+ rtree_test_main(rtree, reporter); |
+ |
+ // Rtree that orders input rectangles on deferred insert. |
+ SkRTree* unsortedRtree = SkRTree::Create(MIN_CHILDREN, MAX_CHILDREN, 1, false); |
+ SkAutoUnref auo(unsortedRtree); |
+ rtree_test_main(unsortedRtree, reporter); |
+} |
+ |
+ |
#include "TestClassDef.h" |
-DEFINE_TESTCLASS("RTree", RTreeTestClass, TestRTree) |
+DEFINE_TESTCLASS("RTree", RTreeTestClass, test_rtree) |