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

Unified Diff: tests/RoundRectTest.cpp

Issue 1373293002: Handle inverted rects in SkRRect creation methods (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fixed SK_ARRAY_COUNT error Created 5 years, 3 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 | « src/core/SkRRect.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/RoundRectTest.cpp
diff --git a/tests/RoundRectTest.cpp b/tests/RoundRectTest.cpp
index 8d8f76fbf0084ee51bd32353cfd7d2f7cd097b19..02dad22e0846d800de69a62fff0ea6d92148cbac 100644
--- a/tests/RoundRectTest.cpp
+++ b/tests/RoundRectTest.cpp
@@ -47,6 +47,61 @@ static void test_empty_crbug_458524(skiatest::Reporter* reporter) {
REPORTER_ASSERT(reporter, SkRRect::kEmpty_Type == other.getType());
}
+// Test that all the SkRRect entry points correctly handle un-sorted and
+// zero-sized input rects
+static void test_empty(skiatest::Reporter* reporter) {
+ static const SkRect oooRects[] = { // out of order
+ { 100, 0, 0, 100 }, // ooo horizontal
+ { 0, 100, 100, 0 }, // ooo vertical
+ { 100, 100, 0, 0 }, // ooo both
+ };
+
+ static const SkRect emptyRects[] = {
+ { 100, 100, 100, 200 }, // empty horizontal
+ { 100, 100, 200, 100 }, // empty vertical
+ { 100, 100, 100, 100 }, // empty both
+ { 0, 0, 0, 0 } // setEmpty-empty
+ };
+
+ static const SkVector radii[4] = { { 0, 1 }, { 2, 3 }, { 4, 5 }, { 6, 7 } };
+
+ SkRRect r;
+
+ for (size_t i = 0; i < SK_ARRAY_COUNT(oooRects); ++i) {
+ r.setRect(oooRects[i]);
+ REPORTER_ASSERT(reporter, !r.isEmpty());
+
+ r.setOval(oooRects[i]);
+ REPORTER_ASSERT(reporter, !r.isEmpty());
+
+ r.setRectXY(oooRects[i], 1, 2);
+ REPORTER_ASSERT(reporter, !r.isEmpty());
+
+ r.setNinePatch(oooRects[i], 0, 1, 2, 3);
+ REPORTER_ASSERT(reporter, !r.isEmpty());
+
+ r.setRectRadii(oooRects[i], radii);
+ REPORTER_ASSERT(reporter, !r.isEmpty());
+ }
+
+ for (size_t i = 0; i < SK_ARRAY_COUNT(emptyRects); ++i) {
+ r.setRect(emptyRects[i]);
+ REPORTER_ASSERT(reporter, r.isEmpty());
+
+ r.setOval(emptyRects[i]);
+ REPORTER_ASSERT(reporter, r.isEmpty());
+
+ r.setRectXY(emptyRects[i], 1, 2);
+ REPORTER_ASSERT(reporter, r.isEmpty());
+
+ r.setNinePatch(emptyRects[i], 0, 1, 2, 3);
+ REPORTER_ASSERT(reporter, r.isEmpty());
+
+ r.setRectRadii(emptyRects[i], radii);
+ REPORTER_ASSERT(reporter, r.isEmpty());
+ }
+}
+
static const SkScalar kWidth = 100.0f;
static const SkScalar kHeight = 100.0f;
@@ -679,4 +734,5 @@ DEF_TEST(RoundRect, reporter) {
test_issue_2696(reporter);
test_tricky_radii(reporter);
test_empty_crbug_458524(reporter);
+ test_empty(reporter);
}
« no previous file with comments | « src/core/SkRRect.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698