| 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;
|
|
|