diff options
author | mtklein <mtklein@chromium.org> | 2014-10-07 09:26:10 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-10-07 09:26:10 -0700 |
commit | fb1fe4f51820731f557e765f8c71cba9a0d28048 (patch) | |
tree | e9fda5dffc33f26459b45c803f4ebd836bad5d1f /tests | |
parent | d909759832d5a6bb476597098e05bbe7ba0ccbd2 (diff) |
Add SkPaint::getHash().
BUG=skia:
Review URL: https://codereview.chromium.org/637583002
Diffstat (limited to 'tests')
-rw-r--r-- | tests/PaintTest.cpp | 26 |
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); +} |