diff options
author | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-03-17 15:39:01 +0000 |
---|---|---|
committer | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-03-17 15:39:01 +0000 |
commit | 761b8e557269bbcd9d8c2030e57666a3d9ccba28 (patch) | |
tree | 430bde064bbf3f71a3c7f0d0b0fc98062cb710e0 /tests/RoundRectTest.cpp | |
parent | 1c556dba153f880cad1f3e2996a320d61435f3c2 (diff) |
Add nine patch type to SkRRect.
BUG=skia:2181
R=robertphillips@google.com, reed@google.com
Author: bsalomon@google.com
Review URL: https://codereview.chromium.org/196343015
git-svn-id: http://skia.googlecode.com/svn/trunk@13833 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests/RoundRectTest.cpp')
-rw-r--r-- | tests/RoundRectTest.cpp | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/tests/RoundRectTest.cpp b/tests/RoundRectTest.cpp index 9b2eecd19c..0a528a6535 100644 --- a/tests/RoundRectTest.cpp +++ b/tests/RoundRectTest.cpp @@ -60,6 +60,13 @@ static void test_round_rect_basic(skiatest::Reporter* reporter) { for (int i = 0; i < 4; ++i) { REPORTER_ASSERT(reporter, zeroPt == rr1.radii((SkRRect::Corner) i)); } + SkRRect rr1_2; // construct the same RR using the most general set function + SkVector rr1_2_radii[4] = { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } }; + rr1_2.setRectRadii(rect, rr1_2_radii); + REPORTER_ASSERT(reporter, rr1_2 == rr1 && rr1_2.getType() == rr1.getType()); + SkRRect rr1_3; // construct the same RR using the nine patch set function + rr1_3.setNinePatch(rect, 0, 0, 0, 0); + REPORTER_ASSERT(reporter, rr1_3 == rr1 && rr1_3.getType() == rr1.getType()); //---- SkPoint halfPoint = { SkScalarHalf(kWidth), SkScalarHalf(kHeight) }; @@ -73,6 +80,14 @@ static void test_round_rect_basic(skiatest::Reporter* reporter) { REPORTER_ASSERT(reporter, rr2.radii((SkRRect::Corner) i).equalsWithinTolerance(halfPoint)); } + SkRRect rr2_2; // construct the same RR using the most general set function + SkVector rr2_2_radii[4] = { { halfPoint.fX, halfPoint.fY }, { halfPoint.fX, halfPoint.fY }, + { halfPoint.fX, halfPoint.fY }, { halfPoint.fX, halfPoint.fY } }; + rr2_2.setRectRadii(rect, rr2_2_radii); + REPORTER_ASSERT(reporter, rr2_2 == rr2 && rr2_2.getType() == rr2.getType()); + SkRRect rr2_3; // construct the same RR using the nine patch set function + rr2_3.setNinePatch(rect, halfPoint.fX, halfPoint.fY, halfPoint.fX, halfPoint.fY); + REPORTER_ASSERT(reporter, rr2_3 == rr2 && rr2_3.getType() == rr2.getType()); //---- SkPoint p = { 5, 5 }; @@ -85,19 +100,33 @@ static void test_round_rect_basic(skiatest::Reporter* reporter) { for (int i = 0; i < 4; ++i) { REPORTER_ASSERT(reporter, p == rr3.radii((SkRRect::Corner) i)); } + SkRRect rr3_2; // construct the same RR using the most general set function + SkVector rr3_2_radii[4] = { { 5, 5 }, { 5, 5 }, { 5, 5 }, { 5, 5 } }; + rr3_2.setRectRadii(rect, rr3_2_radii); + REPORTER_ASSERT(reporter, rr3_2 == rr3 && rr3_2.getType() == rr3.getType()); + SkRRect rr3_3; // construct the same RR using the nine patch set function + rr3_3.setNinePatch(rect, 5, 5, 5, 5); + REPORTER_ASSERT(reporter, rr3_3 == rr3 && rr3_3.getType() == rr3.getType()); //---- - SkPoint radii[4] = { { 5, 5 }, { 5, 5 }, { 5, 5 }, { 5, 5 } }; + SkRect ninePatchRadii = { 10, 9, 8, 7 }; SkRRect rr4; - rr4.setRectRadii(rect, radii); + rr4.setNinePatch(rect, ninePatchRadii.fLeft, ninePatchRadii.fTop, ninePatchRadii.fRight, + ninePatchRadii.fBottom); - REPORTER_ASSERT(reporter, SkRRect::kSimple_Type == rr4.type()); + REPORTER_ASSERT(reporter, SkRRect::kNinePatch_Type == rr4.type()); REPORTER_ASSERT(reporter, rr4.rect() == rect); + SkPoint rquad[4]; + ninePatchRadii.toQuad(rquad); for (int i = 0; i < 4; ++i) { - REPORTER_ASSERT(reporter, radii[i] == rr4.radii((SkRRect::Corner) i)); + REPORTER_ASSERT(reporter, rquad[i] == rr4.radii((SkRRect::Corner) i)); } + SkRRect rr4_2; // construct the same RR using the most general set function + SkVector rr4_2_radii[4] = { { 10, 9 }, { 8, 9 }, {8, 7 }, { 10, 7 } }; + rr4_2.setRectRadii(rect, rr4_2_radii); + REPORTER_ASSERT(reporter, rr4_2 == rr4 && rr4_2.getType() == rr4.getType()); //---- SkPoint radii2[4] = { { 0, 0 }, { 0, 0 }, { 50, 50 }, { 20, 50 } }; @@ -114,7 +143,7 @@ static void test_round_rect_basic(skiatest::Reporter* reporter) { // Test out == & != REPORTER_ASSERT(reporter, empty != rr3); - REPORTER_ASSERT(reporter, rr3 == rr4); + REPORTER_ASSERT(reporter, rr3 != rr4); REPORTER_ASSERT(reporter, rr4 != rr5); } |