diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-07-26 15:20:36 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-07-26 15:20:36 +0000 |
commit | 0bb18bb264b26afca45452910437c09445e23a3c (patch) | |
tree | de94a02e74a789b5a80ad9e6a3b8fdcda9573215 /tests | |
parent | 904160772ed097cd481d6fcd8a3f4bf0a1af8b52 (diff) |
explicitly track if a path is finite or not
we need this (it appears) so we can definitively reject non-finite paths
in canvas, before passing them down into the guts.
Review URL: https://codereview.appspot.com/6453047
git-svn-id: http://skia.googlecode.com/svn/trunk@4784 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests')
-rw-r--r-- | tests/PathTest.cpp | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/tests/PathTest.cpp b/tests/PathTest.cpp index f37760131a..e23ee0e9b1 100644 --- a/tests/PathTest.cpp +++ b/tests/PathTest.cpp @@ -16,6 +16,67 @@ #include "SkSize.h" #include "SkWriter32.h" +static void test_rect_isfinite(skiatest::Reporter* reporter) { + const SkScalar inf = SK_ScalarInfinity; + const SkScalar nan = SK_ScalarNaN; + + SkRect r; + r.setEmpty(); + REPORTER_ASSERT(reporter, r.isFinite()); + r.set(0, 0, inf, -inf); + REPORTER_ASSERT(reporter, !r.isFinite()); + r.set(0, 0, nan, 0); + REPORTER_ASSERT(reporter, !r.isFinite()); + + SkPoint pts[] = { + { 0, 0 }, + { SK_Scalar1, 0 }, + { 0, SK_Scalar1 }, + }; + + bool isFine = r.setBoundsCheck(pts, 3); + REPORTER_ASSERT(reporter, isFine); + REPORTER_ASSERT(reporter, !r.isEmpty()); + + pts[1].set(inf, 0); + isFine = r.setBoundsCheck(pts, 3); + REPORTER_ASSERT(reporter, !isFine); + REPORTER_ASSERT(reporter, r.isEmpty()); + + pts[1].set(nan, 0); + isFine = r.setBoundsCheck(pts, 3); + REPORTER_ASSERT(reporter, !isFine); + REPORTER_ASSERT(reporter, r.isEmpty()); +} + +static void test_path_isfinite(skiatest::Reporter* reporter) { + const SkScalar inf = SK_ScalarInfinity; + const SkScalar nan = SK_ScalarNaN; + + SkPath path; + REPORTER_ASSERT(reporter, path.isFinite()); + + path.reset(); + REPORTER_ASSERT(reporter, path.isFinite()); + + path.reset(); + path.moveTo(SK_Scalar1, 0); + REPORTER_ASSERT(reporter, path.isFinite()); + + path.reset(); + path.moveTo(inf, -inf); + REPORTER_ASSERT(reporter, !path.isFinite()); + + path.reset(); + path.moveTo(nan, 0); + REPORTER_ASSERT(reporter, !path.isFinite()); +} + +static void test_isfinite(skiatest::Reporter* reporter) { + test_rect_isfinite(reporter); + test_path_isfinite(reporter); +} + // assert that we always // start with a moveTo // only have 1 moveTo @@ -1466,6 +1527,7 @@ static void TestPath(skiatest::Reporter* reporter) { test_oval(reporter); test_strokerec(reporter); test_addPoly(reporter); + test_isfinite(reporter); } #include "TestClassDef.h" |