From f68154a3cf43eb22d45be11f3b09e25440c366a6 Mon Sep 17 00:00:00 2001 From: "caryclark@google.com" Date: Wed, 21 Nov 2012 15:18:06 +0000 Subject: Add isRect variant that returns path closure and direction. Add path test to verify that when isRect() returns false, output parameters are unchanged. Review URL: https://codereview.appspot.com/6855074 git-svn-id: http://skia.googlecode.com/svn/trunk@6524 2bbb7eff-a529-9590-31e7-b0007b416f81 --- tests/PathTest.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'tests') diff --git a/tests/PathTest.cpp b/tests/PathTest.cpp index bd41e19ac7..58f864d1e5 100644 --- a/tests/PathTest.cpp +++ b/tests/PathTest.cpp @@ -1052,12 +1052,34 @@ static void test_isRect(skiatest::Reporter* reporter) { path.close(); } REPORTER_ASSERT(reporter, fail ^ path.isRect(0)); + REPORTER_ASSERT(reporter, fail ^ path.isRect(NULL, NULL)); + if (!fail) { SkRect computed, expected; expected.set(tests[testIndex], testLen[testIndex] / sizeof(SkPoint)); REPORTER_ASSERT(reporter, path.isRect(&computed)); REPORTER_ASSERT(reporter, expected == computed); + + bool isClosed; + SkPath::Direction direction, cheapDirection; + REPORTER_ASSERT(reporter, path.cheapComputeDirection(&cheapDirection)); + REPORTER_ASSERT(reporter, path.isRect(&isClosed, &direction)); + REPORTER_ASSERT(reporter, isClosed == close); + REPORTER_ASSERT(reporter, direction == cheapDirection); + } else { + SkRect computed; + computed.set(123, 456, 789, 1011); + REPORTER_ASSERT(reporter, !path.isRect(&computed)); + REPORTER_ASSERT(reporter, computed.fLeft == 123 && computed.fTop == 456); + REPORTER_ASSERT(reporter, computed.fRight == 789 && computed.fBottom == 1011); + + bool isClosed = (bool) -1; + SkPath::Direction direction = (SkPath::Direction) -1; + REPORTER_ASSERT(reporter, !path.isRect(&isClosed, &direction)); + REPORTER_ASSERT(reporter, isClosed == (bool) -1); + REPORTER_ASSERT(reporter, direction == (SkPath::Direction) -1); } + if (tests[testIndex] == lastPass) { fail = true; } -- cgit v1.2.3