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

Unified Diff: tests/PictureTest.cpp

Issue 222683002: Add generation ID to SkPicture (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Fix Ubuntu compiler complaint Created 6 years, 9 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
« include/core/SkPicture.h ('K') | « src/core/SkPicture.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/PictureTest.cpp
===================================================================
--- tests/PictureTest.cpp (revision 14036)
+++ tests/PictureTest.cpp (working copy)
@@ -1142,6 +1142,58 @@
REPORTER_ASSERT(reporter, parentWBWB.willPlayBackBitmaps()); // 2
}
+static void test_gen_id(skiatest::Reporter* reporter) {
+
+ SkPicture hasData, empty, midRecord;
+
+ uint32_t beforeID = hasData.getGenerationID();
+ REPORTER_ASSERT(reporter, SkPicture::kInvalidGenID != beforeID);
+
+ // all 3 pictures should have different ids
+ REPORTER_ASSERT(reporter, beforeID != empty.getGenerationID());
+ REPORTER_ASSERT(reporter, beforeID != midRecord.getGenerationID());
+ REPORTER_ASSERT(reporter, empty.getGenerationID() != midRecord.getGenerationID());
+
+ hasData.beginRecording(1, 1);
+ // gen ID should be invalid mid-record
+ REPORTER_ASSERT(reporter, SkPicture::kInvalidGenID == hasData.getGenerationID());
+ hasData.endRecording();
+ // picture should get a new (non-zero) id after recording
+ REPORTER_ASSERT(reporter, hasData.getGenerationID() != beforeID);
+ REPORTER_ASSERT(reporter, hasData.getGenerationID() != SkPicture::kInvalidGenID);
+
+ midRecord.beginRecording(1, 1);
+ REPORTER_ASSERT(reporter, SkPicture::kInvalidGenID == midRecord.getGenerationID());
+
+ // test out copy constructor
+ SkPicture copyWithData(hasData);
+ REPORTER_ASSERT(reporter, hasData.getGenerationID() == copyWithData.getGenerationID());
+
+ SkPicture emptyCopy(empty);
+ REPORTER_ASSERT(reporter, empty.getGenerationID() != emptyCopy.getGenerationID());
+
+ SkPicture copyMidRecord(midRecord);
+ REPORTER_ASSERT(reporter, midRecord.getGenerationID() != copyMidRecord.getGenerationID());
+ REPORTER_ASSERT(reporter, copyMidRecord.getGenerationID() != SkPicture::kInvalidGenID);
+
+ // test out swap
+ beforeID = copyMidRecord.getGenerationID();
+ copyWithData.swap(copyMidRecord);
+ REPORTER_ASSERT(reporter, copyWithData.getGenerationID() == beforeID);
+ REPORTER_ASSERT(reporter, copyMidRecord.getGenerationID() == hasData.getGenerationID());
+
+ // test out clone
+ SkAutoTUnref<SkPicture> cloneWithData(hasData.clone());
+ REPORTER_ASSERT(reporter, hasData.getGenerationID() == cloneWithData->getGenerationID());
+
+ SkAutoTUnref<SkPicture> emptyClone(empty.clone());
+ REPORTER_ASSERT(reporter, empty.getGenerationID() != emptyClone->getGenerationID());
+
+ SkAutoTUnref<SkPicture> cloneMidRecord(midRecord.clone());
+ REPORTER_ASSERT(reporter, midRecord.getGenerationID() != cloneMidRecord->getGenerationID());
+ REPORTER_ASSERT(reporter, cloneMidRecord->getGenerationID() != SkPicture::kInvalidGenID);
+}
+
DEF_TEST(Picture, reporter) {
#ifdef SK_DEBUG
test_deleting_empty_playback();
@@ -1159,6 +1211,7 @@
test_clip_bound_opt(reporter);
test_clip_expansion(reporter);
test_hierarchical(reporter);
+ test_gen_id(reporter);
}
static void draw_bitmaps(const SkBitmap bitmap, SkCanvas* canvas) {
« include/core/SkPicture.h ('K') | « src/core/SkPicture.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698