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

Unified Diff: tests/CanvasTest.cpp

Issue 2127233002: Added the framework for having canvas/recorder/picture record depth_set's. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Fixed crumbs Created 4 years, 5 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
Index: tests/CanvasTest.cpp
diff --git a/tests/CanvasTest.cpp b/tests/CanvasTest.cpp
index 70c2c04ffabf511239239fe8fe3cf91ab78582af..d52741c94788d3586926a5494bc703c1b6d5f0ba 100644
--- a/tests/CanvasTest.cpp
+++ b/tests/CanvasTest.cpp
@@ -779,6 +779,45 @@ DEF_TEST(Canvas_ClipEmptyPath, reporter) {
canvas.restore();
}
robertphillips 2016/07/11 19:24:52 My suggestion here is to ditch the SkCanvasDrawDep
vjiaoblack 2016/07/11 19:48:13 Done.
+class SkCanvasDrawDepthTester {
+public:
robertphillips 2016/07/11 19:24:53 kCanvasWidth & kCanvasHeight Also, these don't ap
vjiaoblack 2016/07/11 19:48:13 Done.
+ const static int canvasWidth = 100;
+ const static int canvasHeight = 100;
+
+ SkCanvasDrawDepthTester(skiatest::Reporter* reporter) {
robertphillips 2016/07/11 19:24:53 Don't need "this->" here
vjiaoblack 2016/07/11 19:48:13 Done.
+ this->fReporter = reporter;
+ }
+
+ void runTests() {
robertphillips 2016/07/11 19:24:53 testUpdateDepth. The '_' form is for static local
vjiaoblack 2016/07/11 19:48:13 Done.
+ this->test_updatedepth(this->fReporter);
+ }
+
+private:
+ skiatest::Reporter* fReporter;
+
+ void test_updatedepth(skiatest::Reporter* reporter) {
robertphillips 2016/07/11 19:24:52 I don't know what recording into a picture is givi
vjiaoblack 2016/07/11 19:48:13 Done.
+ // set some depths (with picture enabled), then check them as they get set
+ SkPictureRecorder recorder;
+ SkCanvas* canvas;
+ sk_sp<SkPicture> picture;
+
robertphillips 2016/07/11 19:24:52 You could use kCanvasWidth & kCanvasHeight here in
vjiaoblack 2016/07/11 19:48:13 Done.
+ canvas = recorder.beginRecording(SkRect::MakeIWH(100, 100));
+
+ canvas->setZ(-10);
robertphillips 2016/07/11 19:24:53 REPORTER_ASSERT(reporter, canvas->getZ() == -10);
vjiaoblack 2016/07/11 19:48:13 Done.
+ canvas->save();
+ canvas->setZ(10);
+ REPORTER_ASSERT(reporter, canvas->getZ() == 10);
+
+ canvas->restore();
+ REPORTER_ASSERT(reporter, canvas->getZ() == -10);
+
+ canvas->setZ(3.14);
+ REPORTER_ASSERT(reporter, canvas->getZ() == 3.14);
+
+ picture = recorder.finishRecordingAsPicture();
+ }
+};
+
namespace {
class MockFilterCanvas : public SkPaintFilterCanvas {
@@ -812,4 +851,7 @@ DEF_TEST(PaintFilterCanvas_ConsistentState, reporter) {
REPORTER_ASSERT(reporter, canvas.getTotalMatrix() == filterCanvas.getTotalMatrix());
REPORTER_ASSERT(reporter, canvas.getClipBounds(&clip1) == filterCanvas.getClipBounds(&clip2));
REPORTER_ASSERT(reporter, clip1 == clip2);
+
+ SkCanvasDrawDepthTester depthTester(reporter);
+ depthTester.runTests();
}

Powered by Google App Engine
This is Rietveld 408576698