aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/PaintTest.cpp
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2014-10-07 09:26:10 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-10-07 09:26:10 -0700
commitfb1fe4f51820731f557e765f8c71cba9a0d28048 (patch)
treee9fda5dffc33f26459b45c803f4ebd836bad5d1f /tests/PaintTest.cpp
parentd909759832d5a6bb476597098e05bbe7ba0ccbd2 (diff)
Add SkPaint::getHash().
Diffstat (limited to 'tests/PaintTest.cpp')
-rw-r--r--tests/PaintTest.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/PaintTest.cpp b/tests/PaintTest.cpp
index cbb5dadcc5..9b49ec1e85 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);
+}