OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #include "Test.h" | 8 #include "Test.h" |
9 | 9 |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 bitmap.eraseColor(color); | 35 bitmap.eraseColor(color); |
36 } | 36 } |
37 | 37 |
38 void RunTest() { | 38 void RunTest() { |
39 // Test SkBitmapHasher | 39 // Test SkBitmapHasher |
40 SkBitmap bitmap; | 40 SkBitmap bitmap; |
41 SkHashDigest digest; | 41 SkHashDigest digest; |
42 // initial test case | 42 // initial test case |
43 CreateTestBitmap(bitmap, SkBitmap::kARGB_8888_Config, 333, 555, SK_C
olorBLUE); | 43 CreateTestBitmap(bitmap, SkBitmap::kARGB_8888_Config, 333, 555, SK_C
olorBLUE); |
44 REPORTER_ASSERT(fReporter, SkBitmapHasher::ComputeDigest(bitmap, &di
gest)); | 44 REPORTER_ASSERT(fReporter, SkBitmapHasher::ComputeDigest(bitmap, &di
gest)); |
| 45 #ifdef BITMAPHASHER_USES_TRUNCATED_MD5 |
| 46 REPORTER_ASSERT(fReporter, digest == 0xfb2903562766ef87ULL); |
| 47 #else |
45 REPORTER_ASSERT(fReporter, digest == 0x18f9df68b1b02f38ULL); | 48 REPORTER_ASSERT(fReporter, digest == 0x18f9df68b1b02f38ULL); |
| 49 #endif |
46 // same pixel data but different dimensions should yield a different
checksum | 50 // same pixel data but different dimensions should yield a different
checksum |
47 CreateTestBitmap(bitmap, SkBitmap::kARGB_8888_Config, 555, 333, SK_C
olorBLUE); | 51 CreateTestBitmap(bitmap, SkBitmap::kARGB_8888_Config, 555, 333, SK_C
olorBLUE); |
48 REPORTER_ASSERT(fReporter, SkBitmapHasher::ComputeDigest(bitmap, &di
gest)); | 52 REPORTER_ASSERT(fReporter, SkBitmapHasher::ComputeDigest(bitmap, &di
gest)); |
| 53 #ifdef BITMAPHASHER_USES_TRUNCATED_MD5 |
| 54 REPORTER_ASSERT(fReporter, digest == 0xfe04023fb97d0f61ULL); |
| 55 #else |
49 REPORTER_ASSERT(fReporter, digest == 0x6b0298183f786c8eULL); | 56 REPORTER_ASSERT(fReporter, digest == 0x6b0298183f786c8eULL); |
| 57 #endif |
50 // same dimensions but different color should yield a different chec
ksum | 58 // same dimensions but different color should yield a different chec
ksum |
51 CreateTestBitmap(bitmap, SkBitmap::kARGB_8888_Config, 555, 333, SK_C
olorGREEN); | 59 CreateTestBitmap(bitmap, SkBitmap::kARGB_8888_Config, 555, 333, SK_C
olorGREEN); |
52 REPORTER_ASSERT(fReporter, SkBitmapHasher::ComputeDigest(bitmap, &di
gest)); | 60 REPORTER_ASSERT(fReporter, SkBitmapHasher::ComputeDigest(bitmap, &di
gest)); |
| 61 #ifdef BITMAPHASHER_USES_TRUNCATED_MD5 |
| 62 REPORTER_ASSERT(fReporter, digest == 0x2423c51cad6d1edcULL); |
| 63 #else |
53 REPORTER_ASSERT(fReporter, digest == 0xc6b4b3f6fadaaf37ULL); | 64 REPORTER_ASSERT(fReporter, digest == 0xc6b4b3f6fadaaf37ULL); |
| 65 #endif |
54 // same pixel colors in a different config should yield the same che
cksum | 66 // same pixel colors in a different config should yield the same che
cksum |
55 CreateTestBitmap(bitmap, SkBitmap::kARGB_4444_Config, 555, 333, SK_C
olorGREEN); | 67 CreateTestBitmap(bitmap, SkBitmap::kARGB_4444_Config, 555, 333, SK_C
olorGREEN); |
56 REPORTER_ASSERT(fReporter, SkBitmapHasher::ComputeDigest(bitmap, &di
gest)); | 68 REPORTER_ASSERT(fReporter, SkBitmapHasher::ComputeDigest(bitmap, &di
gest)); |
| 69 #ifdef BITMAPHASHER_USES_TRUNCATED_MD5 |
| 70 REPORTER_ASSERT(fReporter, digest == 0x2423c51cad6d1edcULL); |
| 71 #else |
57 REPORTER_ASSERT(fReporter, digest == 0xc6b4b3f6fadaaf37ULL); | 72 REPORTER_ASSERT(fReporter, digest == 0xc6b4b3f6fadaaf37ULL); |
| 73 #endif |
58 } | 74 } |
59 | 75 |
60 Reporter* fReporter; | 76 Reporter* fReporter; |
61 }; | 77 }; |
62 | 78 |
63 static TestRegistry gReg(BitmapHasherTestClass::Factory); | 79 static TestRegistry gReg(BitmapHasherTestClass::Factory); |
64 } | 80 } |
OLD | NEW |