Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Unified Diff: tests/RTreeTest.cpp

Issue 670213002: Cut down SkBBH API more. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: virtual Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/PictureTest.cpp ('k') | tests/RecordDrawTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/RTreeTest.cpp
diff --git a/tests/RTreeTest.cpp b/tests/RTreeTest.cpp
index 6e0622c2fb242a4f77a9ffe06d4bbedb29dd2463..5d5c1cb8735e8fe552da541bb3c6d375c6e68e91 100644
--- a/tests/RTreeTest.cpp
+++ b/tests/RTreeTest.cpp
@@ -29,12 +29,6 @@ static SkRect random_rect(SkRandom& rand) {
return rect;
}
-static void random_data_rects(SkRandom& rand, SkRect out[], int n) {
- for (int i = 0; i < n; ++i) {
- out[i] = random_rect(rand);
- }
-}
-
static bool verify_query(SkRect query, SkRect rects[], SkTDArray<unsigned>& found) {
// TODO(mtklein): no need to do this after everything's SkRects
query.roundOut();
@@ -73,9 +67,7 @@ static void run_queries(skiatest::Reporter* reporter, SkRandom& rand, SkRect rec
}
static void rtree_test_main(SkRTree* rtree, skiatest::Reporter* reporter) {
- SkRect rects[NUM_RECTS];
- SkRandom rand;
- REPORTER_ASSERT(reporter, rtree);
+ SkASSERT(rtree);
int expectedDepthMin = -1;
int expectedDepthMax = -1;
@@ -94,42 +86,23 @@ static void rtree_test_main(SkRTree* rtree, skiatest::Reporter* reporter) {
++expectedDepthMax;
}
+ SkRandom rand;
+ SkAutoTMalloc<SkRect> rects(NUM_RECTS);
for (size_t i = 0; i < NUM_ITERATIONS; ++i) {
- random_data_rects(rand, rects, NUM_RECTS);
-
- // First try bulk-loaded inserts
- for (int i = 0; i < NUM_RECTS; ++i) {
- rtree->insert(i, rects[i], true);
- }
- rtree->flushDeferredInserts();
- run_queries(reporter, rand, rects, *rtree);
- REPORTER_ASSERT(reporter, NUM_RECTS == rtree->getCount());
- REPORTER_ASSERT(reporter, expectedDepthMin <= rtree->getDepth() &&
- expectedDepthMax >= rtree->getDepth());
rtree->clear();
REPORTER_ASSERT(reporter, 0 == rtree->getCount());
- // Then try immediate inserts
- for (int i = 0; i < NUM_RECTS; ++i) {
- rtree->insert(i, rects[i]);
+ for (int j = 0; j < NUM_RECTS; j++) {
+ rects[j] = random_rect(rand);
}
- run_queries(reporter, rand, rects, *rtree);
- REPORTER_ASSERT(reporter, NUM_RECTS == rtree->getCount());
- REPORTER_ASSERT(reporter, expectedDepthMin <= rtree->getDepth() &&
- expectedDepthMax >= rtree->getDepth());
- rtree->clear();
- REPORTER_ASSERT(reporter, 0 == rtree->getCount());
- // And for good measure try immediate inserts, but in reversed order
- for (int i = NUM_RECTS - 1; i >= 0; --i) {
- rtree->insert(i, rects[i]);
- }
+ rtree->insert(&rects, NUM_RECTS);
+ SkASSERT(rects); // SkRTree doesn't take ownership of rects.
+
run_queries(reporter, rand, rects, *rtree);
REPORTER_ASSERT(reporter, NUM_RECTS == rtree->getCount());
REPORTER_ASSERT(reporter, expectedDepthMin <= rtree->getDepth() &&
expectedDepthMax >= rtree->getDepth());
- rtree->clear();
- REPORTER_ASSERT(reporter, 0 == rtree->getCount());
}
}
« no previous file with comments | « tests/PictureTest.cpp ('k') | tests/RecordDrawTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698