Fix result order reliance
authorcommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 17 Mar 2014 12:14:48 +0000 (12:14 +0000)
committercommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 17 Mar 2014 12:14:48 +0000 (12:14 +0000)
The old tests presumed result order in a way was safe because SkPicture was sorting the paint calls.
This fixes the tests to not check result ordering, just presence

BUG=skia:
R=robertphillips@google.com

Author: iancottrell@google.com

Review URL: https://codereview.chromium.org/197813011

git-svn-id: http://skia.googlecode.com/svn/trunk@13828 2bbb7eff-a529-9590-31e7-b0007b416f81

tests/TileGridTest.cpp

index cafcc8e..ef2d796 100644 (file)
@@ -64,53 +64,53 @@ DEF_TEST(TileGrid_UnalignedQuery, reporter) {
         SkTDArray<void*> rects;
         grid.search(query(0.0f, 0.0f, 1.0f, 1.0f), &rects);
         REPORTER_ASSERT(reporter, 1 == rects.count());
-        REPORTER_ASSERT(reporter, &rect1 == rects[0]);
+        REPORTER_ASSERT(reporter, rects.find(&rect1) >= 0);
     }
     {
         SkTDArray<void*> rects;
         grid.search(query(7.99f, 7.99f, 1.0f, 1.0f), &rects);
         REPORTER_ASSERT(reporter, 1 == rects.count());
-        REPORTER_ASSERT(reporter, &rect1 == rects[0]);
+        REPORTER_ASSERT(reporter, rects.find(&rect1) >= 0);
     }
     // Corner overlap
     {
         SkTDArray<void*> rects;
         grid.search(query(9.5f, 9.5f, 1.0f, 1.0f), &rects);
         REPORTER_ASSERT(reporter, 2 == rects.count());
-        REPORTER_ASSERT(reporter, &rect1 == rects[0]);
-        REPORTER_ASSERT(reporter, &rect2 == rects[1]);
+        REPORTER_ASSERT(reporter, rects.find(&rect1) >= 0);
+        REPORTER_ASSERT(reporter, rects.find(&rect2) >= 0);
     }
     // Intersect bottom right tile, but does not overlap rect 2
     {
         SkTDArray<void*> rects;
         grid.search(query(16.0f, 16.0f, 1.0f, 1.0f), &rects);
         REPORTER_ASSERT(reporter, 1 == rects.count());
-        REPORTER_ASSERT(reporter, &rect2 == rects[0]);
+        REPORTER_ASSERT(reporter, rects.find(&rect2) >= 0);
     }
     // Out of bounds queries, snap to border tiles
     {
         SkTDArray<void*> rects;
         grid.search(query(-2.0f, 0.0f, 1.0f, 1.0f), &rects);
         REPORTER_ASSERT(reporter, 1 == rects.count());
-        REPORTER_ASSERT(reporter, &rect1 == rects[0]);
+        REPORTER_ASSERT(reporter, rects.find(&rect1) >= 0);
     }
     {
         SkTDArray<void*> rects;
         grid.search(query(0.0f, -2.0f, 1.0f, 1.0f), &rects);
         REPORTER_ASSERT(reporter, 1 == rects.count());
-        REPORTER_ASSERT(reporter, &rect1 == rects[0]);
+        REPORTER_ASSERT(reporter, rects.find(&rect1) >= 0);
     }
     {
         SkTDArray<void*> rects;
         grid.search(query(22.0f, 16.0f, 1.0f, 1.0f), &rects);
         REPORTER_ASSERT(reporter, 1 == rects.count());
-        REPORTER_ASSERT(reporter, &rect2 == rects[0]);
+        REPORTER_ASSERT(reporter, rects.find(&rect2) >= 0);
     }
     {
         SkTDArray<void*> rects;
         grid.search(query(16.0f, 22.0f, 1.0f, 1.0f), &rects);
         REPORTER_ASSERT(reporter, 1 == rects.count());
-        REPORTER_ASSERT(reporter, &rect2 == rects[0]);
+        REPORTER_ASSERT(reporter, rects.find(&rect2) >= 0);
     }
 }
 
@@ -139,15 +139,15 @@ DEF_TEST(TileGrid_OverlapOffsetQueryAlignment, reporter) {
         SkTDArray<void*> rects;
         grid.search(query(0.0f, 0.0f, 10.0f, 10.0f), &rects);
         REPORTER_ASSERT(reporter, 1 == rects.count());
-        REPORTER_ASSERT(reporter, &rect1 == rects[0]);
+        REPORTER_ASSERT(reporter, rects.find(&rect1) >= 0);
     }
     {
         // Encroaching border by one pixel
         SkTDArray<void*> rects;
         grid.search(query(0.0f, 0.0f, 11.0f, 11.0f), &rects);
         REPORTER_ASSERT(reporter, 2 == rects.count());
-        REPORTER_ASSERT(reporter, &rect1 == rects[0]);
-        REPORTER_ASSERT(reporter, &rect2 == rects[1]);
+        REPORTER_ASSERT(reporter, rects.find(&rect1) >= 0);
+        REPORTER_ASSERT(reporter, rects.find(&rect2) >= 0);
     }
     {
         // Tile stride is 8 (tileWidth - 2 * border pixels
@@ -156,21 +156,21 @@ DEF_TEST(TileGrid_OverlapOffsetQueryAlignment, reporter) {
         SkTDArray<void*> rects;
         grid.search(query(8.0f, 8.0f, 10.0f, 10.0f), &rects);
         REPORTER_ASSERT(reporter, 1 == rects.count());
-        REPORTER_ASSERT(reporter, &rect2 == rects[0]);
+        REPORTER_ASSERT(reporter, rects.find(&rect2) >= 0);
     }
     {
         SkTDArray<void*> rects;
         grid.search(query(7.9f, 7.9f, 10.0f, 10.0f), &rects);
         REPORTER_ASSERT(reporter, 2 == rects.count());
-        REPORTER_ASSERT(reporter, &rect1 == rects[0]);
-        REPORTER_ASSERT(reporter, &rect2 == rects[1]);
+        REPORTER_ASSERT(reporter, rects.find(&rect1) >= 0);
+        REPORTER_ASSERT(reporter, rects.find(&rect2) >= 0);
     }
     {
         SkTDArray<void*> rects;
         grid.search(query(8.1f, 8.1f, 10.0f, 10.0f), &rects);
         REPORTER_ASSERT(reporter, 2 == rects.count());
-        REPORTER_ASSERT(reporter, &rect2 == rects[0]);
-        REPORTER_ASSERT(reporter, &rect3 == rects[1]);
+        REPORTER_ASSERT(reporter, rects.find(&rect2) >= 0);
+        REPORTER_ASSERT(reporter, rects.find(&rect3) >= 0);
     }
     {
         // Regression test for crbug.com/234688