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

Unified Diff: tests/BitmapHasherTest.cpp

Issue 14265010: Make SkSHA1 and SkM5 use common SkDigestHash result type (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: sync_to_r8826 Created 7 years, 8 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/utils/SkHashDigest.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/BitmapHasherTest.cpp
===================================================================
--- tests/BitmapHasherTest.cpp (revision 8826)
+++ tests/BitmapHasherTest.cpp (working copy)
@@ -10,10 +10,8 @@
#include "SkBitmap.h"
#include "SkBitmapHasher.h"
#include "SkColor.h"
+#include "SkHashDigest.h"
-// Word size that is large enough to hold results of any checksum type.
-typedef uint64_t checksum_result;
-
namespace skiatest {
class BitmapHasherTestClass : public Test {
public:
@@ -38,23 +36,46 @@
void RunTest() {
// Test SkBitmapHasher
SkBitmap bitmap;
- SkHashDigest digest;
+ BITMAP_HASH_TYPE actualDigest;
+
// initial test case
CreateTestBitmap(bitmap, SkBitmap::kARGB_8888_Config, 333, 555, SK_ColorBLUE);
- REPORTER_ASSERT(fReporter, SkBitmapHasher::ComputeDigest(bitmap, &digest));
- REPORTER_ASSERT(fReporter, digest == 0x18f9df68b1b02f38ULL);
+ REPORTER_ASSERT(fReporter, SkBitmapHasher::ComputeDigest(bitmap, &actualDigest));
+#ifdef BITMAP_HASH_TYPE_SkHashDigest
+ BITMAP_HASH_TYPE expectedDigest;
+ REPORTER_ASSERT(fReporter, expectedDigest.copyFromHexString("87ef6627560329fb8a2439ee7023e027"));
+ REPORTER_ASSERT(fReporter, actualDigest == expectedDigest);
+ REPORTER_ASSERT(fReporter, actualDigest.toHexString().equals("87ef6627560329fb8a2439ee7023e027"));
+#else
+ REPORTER_ASSERT(fReporter, actualDigest == 0x18f9df68b1b02f38ULL);
+#endif
+
// same pixel data but different dimensions should yield a different checksum
CreateTestBitmap(bitmap, SkBitmap::kARGB_8888_Config, 555, 333, SK_ColorBLUE);
- REPORTER_ASSERT(fReporter, SkBitmapHasher::ComputeDigest(bitmap, &digest));
- REPORTER_ASSERT(fReporter, digest == 0x6b0298183f786c8eULL);
+ REPORTER_ASSERT(fReporter, SkBitmapHasher::ComputeDigest(bitmap, &actualDigest));
+#ifdef BITMAP_HASH_TYPE_SkHashDigest
+ REPORTER_ASSERT(fReporter, actualDigest.toHexString().equals("610f7db93f0204fe956ef415d830d76e"));
+#else
+ REPORTER_ASSERT(fReporter, actualDigest == 0x6b0298183f786c8eULL);
+#endif
+
// same dimensions but different color should yield a different checksum
CreateTestBitmap(bitmap, SkBitmap::kARGB_8888_Config, 555, 333, SK_ColorGREEN);
- REPORTER_ASSERT(fReporter, SkBitmapHasher::ComputeDigest(bitmap, &digest));
- REPORTER_ASSERT(fReporter, digest == 0xc6b4b3f6fadaaf37ULL);
+ REPORTER_ASSERT(fReporter, SkBitmapHasher::ComputeDigest(bitmap, &actualDigest));
+#ifdef BITMAP_HASH_TYPE_SkHashDigest
+ REPORTER_ASSERT(fReporter, actualDigest.toHexString().equals("dc1e6dad1cc5232459158596fd3bc856"));
+#else
+ REPORTER_ASSERT(fReporter, actualDigest == 0xc6b4b3f6fadaaf37ULL);
+#endif
+
// same pixel colors in a different config should yield the same checksum
CreateTestBitmap(bitmap, SkBitmap::kARGB_4444_Config, 555, 333, SK_ColorGREEN);
- REPORTER_ASSERT(fReporter, SkBitmapHasher::ComputeDigest(bitmap, &digest));
- REPORTER_ASSERT(fReporter, digest == 0xc6b4b3f6fadaaf37ULL);
+ REPORTER_ASSERT(fReporter, SkBitmapHasher::ComputeDigest(bitmap, &actualDigest));
+#ifdef BITMAP_HASH_TYPE_SkHashDigest
+ REPORTER_ASSERT(fReporter, actualDigest.toHexString().equals("dc1e6dad1cc5232459158596fd3bc856"));
+#else
+ REPORTER_ASSERT(fReporter, actualDigest == 0xc6b4b3f6fadaaf37ULL);
+#endif
}
Reporter* fReporter;
« no previous file with comments | « src/utils/SkHashDigest.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698