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

Side by Side Diff: tests/BitmapHasherTest.cpp

Issue 184233003: remove deprecated use of bitmap config from tests (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/BitmapGetColorTest.cpp ('k') | tests/BlitRowTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkBitmapHasher.h" 8 #include "SkBitmapHasher.h"
9 9
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
11 #include "SkColor.h" 11 #include "SkColor.h"
12 #include "Test.h" 12 #include "Test.h"
13 13
14 // Word size that is large enough to hold results of any checksum type. 14 // Word size that is large enough to hold results of any checksum type.
15 typedef uint64_t checksum_result; 15 typedef uint64_t checksum_result;
16 16
17 // Fill in bitmap with test data. 17 // Fill in bitmap with test data.
18 static void CreateTestBitmap(SkBitmap &bitmap, SkBitmap::Config config, int widt h, int height, 18 static void CreateTestBitmap(SkBitmap* bitmap, int width, int height,
19 SkColor color, skiatest::Reporter* reporter) { 19 SkColor color, skiatest::Reporter* reporter) {
20 bitmap.setConfig(config, width, height); 20 SkImageInfo info = SkImageInfo::MakeN32(width, height, kOpaque_SkAlphaType);
21 REPORTER_ASSERT(reporter, bitmap.allocPixels()); 21 REPORTER_ASSERT(reporter, bitmap->allocPixels(info));
22 bitmap.setAlphaType(kOpaque_SkAlphaType); 22 bitmap->eraseColor(color);
23 bitmap.eraseColor(color);
24 } 23 }
25 24
26 DEF_TEST(BitmapHasher, reporter) { 25 DEF_TEST(BitmapHasher, reporter) {
27 // Test SkBitmapHasher 26 // Test SkBitmapHasher
28 SkBitmap bitmap; 27 SkBitmap bitmap;
29 uint64_t digest; 28 uint64_t digest;
30 // initial test case 29 // initial test case
31 CreateTestBitmap(bitmap, SkBitmap::kARGB_8888_Config, 333, 555, SK_ColorBLUE , reporter); 30 CreateTestBitmap(&bitmap, 333, 555, SK_ColorBLUE, reporter);
32 REPORTER_ASSERT(reporter, SkBitmapHasher::ComputeDigest(bitmap, &digest)); 31 REPORTER_ASSERT(reporter, SkBitmapHasher::ComputeDigest(bitmap, &digest));
33 REPORTER_ASSERT(reporter, digest == 0xfb2903562766ef87ULL); 32 REPORTER_ASSERT(reporter, digest == 0xfb2903562766ef87ULL);
34 // same pixel data but different dimensions should yield a different checksu m 33 // same pixel data but different dimensions should yield a different checksu m
35 CreateTestBitmap(bitmap, SkBitmap::kARGB_8888_Config, 555, 333, SK_ColorBLUE , reporter); 34 CreateTestBitmap(&bitmap, 555, 333, SK_ColorBLUE, reporter);
36 REPORTER_ASSERT(reporter, SkBitmapHasher::ComputeDigest(bitmap, &digest)); 35 REPORTER_ASSERT(reporter, SkBitmapHasher::ComputeDigest(bitmap, &digest));
37 REPORTER_ASSERT(reporter, digest == 0xfe04023fb97d0f61ULL); 36 REPORTER_ASSERT(reporter, digest == 0xfe04023fb97d0f61ULL);
38 // same dimensions but different color should yield a different checksum 37 // same dimensions but different color should yield a different checksum
39 CreateTestBitmap(bitmap, SkBitmap::kARGB_8888_Config, 555, 333, SK_ColorGREE N, reporter); 38 CreateTestBitmap(&bitmap, 555, 333, SK_ColorGREEN, reporter);
40 REPORTER_ASSERT(reporter, SkBitmapHasher::ComputeDigest(bitmap, &digest)); 39 REPORTER_ASSERT(reporter, SkBitmapHasher::ComputeDigest(bitmap, &digest));
41 REPORTER_ASSERT(reporter, digest == 0x2423c51cad6d1edcULL); 40 REPORTER_ASSERT(reporter, digest == 0x2423c51cad6d1edcULL);
42 } 41 }
OLDNEW
« no previous file with comments | « tests/BitmapGetColorTest.cpp ('k') | tests/BlitRowTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698