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

Unified Diff: tests/PaintTest.cpp

Issue 637583002: Add SkPaint::getHash(). (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: better Created 6 years, 2 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
« no previous file with comments | « src/core/SkPaint.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/PaintTest.cpp
diff --git a/tests/PaintTest.cpp b/tests/PaintTest.cpp
index cbb5dadcc523958efb19d33397cb766a7abdba38..9b49ec1e8517b659e7dd3d7858cc4a3239fa9a30 100644
--- a/tests/PaintTest.cpp
+++ b/tests/PaintTest.cpp
@@ -343,3 +343,29 @@ DEF_TEST(Paint_MoreFlattening, r) {
ASSERT(paint.getXfermode()->asMode(&paintMode));
ASSERT(otherMode == paintMode);
}
+
+DEF_TEST(Paint_getHash, r) {
+ // Try not to inspect the actual hash values in here.
+ // We might want to change the hash function.
+
+ SkPaint paint;
+ const uint32_t defaultHash = paint.getHash();
+
+ // Check that some arbitrary field affects the hash.
+ paint.setColor(0xFF00FF00);
+ REPORTER_ASSERT(r, paint.getHash() != defaultHash);
+ paint.setColor(SK_ColorBLACK); // Reset to default value.
+ REPORTER_ASSERT(r, paint.getHash() == defaultHash);
+
+ // SkTypeface is the first field we hash, so test it specially.
+ paint.setTypeface(SkTypeface::RefDefault())->unref();
+ REPORTER_ASSERT(r, paint.getHash() != defaultHash);
+ paint.setTypeface(NULL);
+ REPORTER_ASSERT(r, paint.getHash() == defaultHash);
+
+ // This is part of fBitfields, the last field we hash.
+ paint.setHinting(SkPaint::kSlight_Hinting);
+ REPORTER_ASSERT(r, paint.getHash() != defaultHash);
+ paint.setHinting(SkPaint::kNormal_Hinting);
+ REPORTER_ASSERT(r, paint.getHash() == defaultHash);
+}
« no previous file with comments | « src/core/SkPaint.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698