From cd667b6e581b5f3060caf7a959ac6ef50fd33266 Mon Sep 17 00:00:00 2001 From: Mike Reed Date: Thu, 2 Mar 2017 15:21:11 -0500 Subject: [PATCH] add unittests for clip-state queries BUG=skia: Change-Id: I6f8d5a0e78c5b41caa6c6388f7f2ace050ed08ac Reviewed-on: https://skia-review.googlesource.com/9171 Reviewed-by: Mike Reed Reviewed-by: Cary Clark Commit-Queue: Mike Reed --- tests/CanvasTest.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/CanvasTest.cpp b/tests/CanvasTest.cpp index c947ce4..af18938 100644 --- a/tests/CanvasTest.cpp +++ b/tests/CanvasTest.cpp @@ -813,3 +813,32 @@ DEF_TEST(CanvasStack, r) { REPORTER_ASSERT(r, !life[0]); REPORTER_ASSERT(r, !life[1]); } + +DEF_TEST(CanvasClipType, r) { + sk_sp surf = SkSurface::MakeRasterN32Premul(10, 10); + SkCanvas* canvas = surf->getCanvas(); + + REPORTER_ASSERT(r, !canvas->isClipEmpty()); + REPORTER_ASSERT(r, canvas->isClipRect()); + + canvas->save(); + canvas->clipRect({0, 0, 0, 0}); + REPORTER_ASSERT(r, canvas->isClipEmpty()); + REPORTER_ASSERT(r, !canvas->isClipRect()); + canvas->restore(); + + canvas->save(); + canvas->clipRect({2, 2, 6, 6}); + REPORTER_ASSERT(r, !canvas->isClipEmpty()); + REPORTER_ASSERT(r, canvas->isClipRect()); + canvas->restore(); + + canvas->save(); + canvas->clipRect({2, 2, 6, 6}, SkClipOp::kDifference); // punch a hole in the clip + REPORTER_ASSERT(r, !canvas->isClipEmpty()); + REPORTER_ASSERT(r, !canvas->isClipRect()); + canvas->restore(); + + REPORTER_ASSERT(r, !canvas->isClipEmpty()); + REPORTER_ASSERT(r, canvas->isClipRect()); +} -- 2.7.4