Chromium Code Reviews| Index: tests/PictureTest.cpp |
| diff --git a/tests/PictureTest.cpp b/tests/PictureTest.cpp |
| index 5bc60371c997f957f56a0f122602812822c813fb..728ecedb4ba4adaeffbb094a996871f060e9614d 100644 |
| --- a/tests/PictureTest.cpp |
| +++ b/tests/PictureTest.cpp |
| @@ -1721,6 +1721,20 @@ static void test_gen_id(skiatest::Reporter* reporter) { |
| REPORTER_ASSERT(reporter, hasData->uniqueID() != empty->uniqueID()); |
| } |
| +static void test_bytes_used(skiatest::Reporter* reporter) { |
| + SkPictureRecorder recorder; |
| + |
| + recorder.beginRecording(0, 0); |
| + SkAutoTUnref<SkPicture> empty(recorder.endRecording()); |
| + |
| + // A SkPicture also has SkRecord and possibly SkBBHierarchy as members. |
|
mtklein
2014/11/17 21:43:20
As written, there will be no BBH. Did you want to
|
| + REPORTER_ASSERT(reporter, SkPictureUtils::approximateBytesUsed(empty.get()) >= |
| + sizeof(SkPicture)); |
| + |
| + // Protect against any unintentional bloat. |
| + REPORTER_ASSERT(reporter, SkPictureUtils::approximateBytesUsed(empty.get()) <= 176); |
| +} |
| + |
| DEF_TEST(Picture, reporter) { |
| #ifdef SK_DEBUG |
| test_deleting_empty_picture(); |
| @@ -1743,6 +1757,7 @@ DEF_TEST(Picture, reporter) { |
| test_hierarchical(reporter); |
| test_gen_id(reporter); |
| test_savelayer_extraction(reporter); |
| + test_bytes_used(reporter); |
| } |
| static void draw_bitmaps(const SkBitmap bitmap, SkCanvas* canvas) { |
| @@ -1837,6 +1852,7 @@ struct CountingBBH : public SkBBoxHierarchy { |
| } |
| virtual void insert(SkAutoTMalloc<SkRect>*, int) SK_OVERRIDE {} |
| + virtual size_t bytesUsed() const { return 0; } |
| }; |
| class SpoonFedBBHFactory : public SkBBHFactory { |