| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "Test.h" | 8 #include "Test.h" |
| 9 | 9 |
| 10 #include "SkPictureRecorder.h" | 10 #include "SkPictureRecorder.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 recorder.endCommentGroup(); | 62 recorder.endCommentGroup(); |
| 63 | 63 |
| 64 Tally tally; | 64 Tally tally; |
| 65 tally.apply(record); | 65 tally.apply(record); |
| 66 | 66 |
| 67 REPORTER_ASSERT(r, 1 == tally.count<SkRecords::BeginCommentGroup>()); | 67 REPORTER_ASSERT(r, 1 == tally.count<SkRecords::BeginCommentGroup>()); |
| 68 REPORTER_ASSERT(r, 2 == tally.count<SkRecords::AddComment>()); | 68 REPORTER_ASSERT(r, 2 == tally.count<SkRecords::AddComment>()); |
| 69 REPORTER_ASSERT(r, 1 == tally.count<SkRecords::EndCommentGroup>()); | 69 REPORTER_ASSERT(r, 1 == tally.count<SkRecords::EndCommentGroup>()); |
| 70 } | 70 } |
| 71 | 71 |
| 72 // DrawData is similar to comment groups. It doesn't affect drawing, but | |
| 73 // it's a pass-through we provide to the client. Again, a simple reg. test. | |
| 74 DEF_TEST(Recorder_DrawData, r) { | |
| 75 SkRecord record; | |
| 76 SkRecorder recorder(&record, 100, 100); | |
| 77 | |
| 78 const char* data = "This sure is some data, eh?"; | |
| 79 recorder.drawData(data, strlen(data)); | |
| 80 | |
| 81 Tally tally; | |
| 82 tally.apply(record); | |
| 83 REPORTER_ASSERT(r, 1 == tally.count<SkRecords::DrawData>()); | |
| 84 } | |
| 85 | |
| 86 // Regression test for leaking refs held by optional arguments. | 72 // Regression test for leaking refs held by optional arguments. |
| 87 DEF_TEST(Recorder_RefLeaking, r) { | 73 DEF_TEST(Recorder_RefLeaking, r) { |
| 88 // We use SaveLayer to test: | 74 // We use SaveLayer to test: |
| 89 // - its SkRect argument is optional and SkRect is POD. Just testing that
that works. | 75 // - its SkRect argument is optional and SkRect is POD. Just testing that
that works. |
| 90 // - its SkPaint argument is optional and SkPaint is not POD. The bug was
here. | 76 // - its SkPaint argument is optional and SkPaint is not POD. The bug was
here. |
| 91 | 77 |
| 92 SkRect bounds = SkRect::MakeWH(320, 240); | 78 SkRect bounds = SkRect::MakeWH(320, 240); |
| 93 SkPaint paint; | 79 SkPaint paint; |
| 94 paint.setShader(SkShader::CreateEmptyShader())->unref(); | 80 paint.setShader(SkShader::CreateEmptyShader())->unref(); |
| 95 | 81 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 recorder.drawImageRect(image.get(), 0, SkRect::MakeWH(100, 100)); | 142 recorder.drawImageRect(image.get(), 0, SkRect::MakeWH(100, 100)); |
| 157 REPORTER_ASSERT(reporter, !image->unique()); | 143 REPORTER_ASSERT(reporter, !image->unique()); |
| 158 | 144 |
| 159 Tally tally; | 145 Tally tally; |
| 160 tally.apply(record); | 146 tally.apply(record); |
| 161 | 147 |
| 162 REPORTER_ASSERT(reporter, 1 == tally.count<SkRecords::DrawImageRect>()); | 148 REPORTER_ASSERT(reporter, 1 == tally.count<SkRecords::DrawImageRect>()); |
| 163 } | 149 } |
| 164 REPORTER_ASSERT(reporter, image->unique()); | 150 REPORTER_ASSERT(reporter, image->unique()); |
| 165 } | 151 } |
| OLD | NEW |