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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 SkRecord record; | 43 SkRecord record; |
44 SkRecorder recorder(&record, 1920, 1080); | 44 SkRecorder recorder(&record, 1920, 1080); |
45 | 45 |
46 recorder.drawRect(SkRect::MakeWH(10, 10), SkPaint()); | 46 recorder.drawRect(SkRect::MakeWH(10, 10), SkPaint()); |
47 | 47 |
48 Tally tally; | 48 Tally tally; |
49 tally.apply(record); | 49 tally.apply(record); |
50 REPORTER_ASSERT(r, 1 == tally.count<SkRecords::DrawRect>()); | 50 REPORTER_ASSERT(r, 1 == tally.count<SkRecords::DrawRect>()); |
51 } | 51 } |
52 | 52 |
53 // All of Skia will work fine without support for comment groups, but | |
54 // Chrome's inspector can break. This serves as a simple regression test. | |
55 DEF_TEST(Recorder_CommentGroups, r) { | |
56 SkRecord record; | |
57 SkRecorder recorder(&record, 1920, 1080); | |
58 | |
59 recorder.beginCommentGroup("test"); | |
60 recorder.addComment("foo", "bar"); | |
61 recorder.addComment("baz", "quux"); | |
62 recorder.endCommentGroup(); | |
63 | |
64 Tally tally; | |
65 tally.apply(record); | |
66 | |
67 REPORTER_ASSERT(r, 1 == tally.count<SkRecords::BeginCommentGroup>()); | |
68 REPORTER_ASSERT(r, 2 == tally.count<SkRecords::AddComment>()); | |
69 REPORTER_ASSERT(r, 1 == tally.count<SkRecords::EndCommentGroup>()); | |
70 } | |
71 | |
72 // Regression test for leaking refs held by optional arguments. | 53 // Regression test for leaking refs held by optional arguments. |
73 DEF_TEST(Recorder_RefLeaking, r) { | 54 DEF_TEST(Recorder_RefLeaking, r) { |
74 // We use SaveLayer to test: | 55 // We use SaveLayer to test: |
75 // - its SkRect argument is optional and SkRect is POD. Just testing that
that works. | 56 // - its SkRect argument is optional and SkRect is POD. Just testing that
that works. |
76 // - its SkPaint argument is optional and SkPaint is not POD. The bug was
here. | 57 // - its SkPaint argument is optional and SkPaint is not POD. The bug was
here. |
77 | 58 |
78 SkRect bounds = SkRect::MakeWH(320, 240); | 59 SkRect bounds = SkRect::MakeWH(320, 240); |
79 SkPaint paint; | 60 SkPaint paint; |
80 paint.setShader(SkShader::CreateEmptyShader())->unref(); | 61 paint.setShader(SkShader::CreateEmptyShader())->unref(); |
81 | 62 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 recorder.drawImageRect(image.get(), 0, SkRect::MakeWH(100, 100)); | 101 recorder.drawImageRect(image.get(), 0, SkRect::MakeWH(100, 100)); |
121 REPORTER_ASSERT(reporter, !image->unique()); | 102 REPORTER_ASSERT(reporter, !image->unique()); |
122 | 103 |
123 Tally tally; | 104 Tally tally; |
124 tally.apply(record); | 105 tally.apply(record); |
125 | 106 |
126 REPORTER_ASSERT(reporter, 1 == tally.count<SkRecords::DrawImageRect>()); | 107 REPORTER_ASSERT(reporter, 1 == tally.count<SkRecords::DrawImageRect>()); |
127 } | 108 } |
128 REPORTER_ASSERT(reporter, image->unique()); | 109 REPORTER_ASSERT(reporter, image->unique()); |
129 } | 110 } |
OLD | NEW |