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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 SkRecord record; | 42 SkRecord record; |
43 SkRecorder recorder(&record, 1920, 1080); | 43 SkRecorder recorder(&record, 1920, 1080); |
44 | 44 |
45 recorder.drawRect(SkRect::MakeWH(10, 10), SkPaint()); | 45 recorder.drawRect(SkRect::MakeWH(10, 10), SkPaint()); |
46 | 46 |
47 Tally tally; | 47 Tally tally; |
48 tally.apply(record); | 48 tally.apply(record); |
49 REPORTER_ASSERT(r, 1 == tally.count<SkRecords::DrawRect>()); | 49 REPORTER_ASSERT(r, 1 == tally.count<SkRecords::DrawRect>()); |
50 } | 50 } |
51 | 51 |
| 52 // All of Skia will work fine without support for comment groups, but |
| 53 // Chrome's inspector can break. This serves as a simple regression test. |
| 54 DEF_TEST(Recorder_CommentGroups, r) { |
| 55 SkRecord record; |
| 56 SkRecorder recorder(&record, 1920, 1080); |
| 57 |
| 58 recorder.beginCommentGroup("test"); |
| 59 recorder.addComment("foo", "bar"); |
| 60 recorder.addComment("baz", "quux"); |
| 61 recorder.endCommentGroup(); |
| 62 |
| 63 Tally tally; |
| 64 tally.apply(record); |
| 65 |
| 66 REPORTER_ASSERT(r, 1 == tally.count<SkRecords::BeginCommentGroup>()); |
| 67 REPORTER_ASSERT(r, 2 == tally.count<SkRecords::AddComment>()); |
| 68 REPORTER_ASSERT(r, 1 == tally.count<SkRecords::EndCommentGroup>()); |
| 69 } |
| 70 |
52 // Regression test for leaking refs held by optional arguments. | 71 // Regression test for leaking refs held by optional arguments. |
53 DEF_TEST(Recorder_RefLeaking, r) { | 72 DEF_TEST(Recorder_RefLeaking, r) { |
54 // We use SaveLayer to test: | 73 // We use SaveLayer to test: |
55 // - its SkRect argument is optional and SkRect is POD. Just testing that
that works. | 74 // - its SkRect argument is optional and SkRect is POD. Just testing that
that works. |
56 // - its SkPaint argument is optional and SkPaint is not POD. The bug was
here. | 75 // - its SkPaint argument is optional and SkPaint is not POD. The bug was
here. |
57 | 76 |
58 SkRect bounds = SkRect::MakeWH(320, 240); | 77 SkRect bounds = SkRect::MakeWH(320, 240); |
59 SkPaint paint; | 78 SkPaint paint; |
60 paint.setShader(SkShader::CreateEmptyShader())->unref(); | 79 paint.setShader(SkShader::CreateEmptyShader())->unref(); |
61 | 80 |
(...skipping 21 matching lines...) Expand all Loading... |
83 { | 102 { |
84 SkRecord record; | 103 SkRecord record; |
85 SkRecorder recorder(&record, 100, 100); | 104 SkRecorder recorder(&record, 100, 100); |
86 recorder.drawPicture(pic); | 105 recorder.drawPicture(pic); |
87 // the recorder should now also be an owner | 106 // the recorder should now also be an owner |
88 REPORTER_ASSERT(r, !pic->unique()); | 107 REPORTER_ASSERT(r, !pic->unique()); |
89 } | 108 } |
90 // the recorder destructor should have released us (back to unique) | 109 // the recorder destructor should have released us (back to unique) |
91 REPORTER_ASSERT(r, pic->unique()); | 110 REPORTER_ASSERT(r, pic->unique()); |
92 } | 111 } |
OLD | NEW |