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

Unified Diff: chrome/browser/webdata/web_database_unittest.cc

Issue 150107: Reland of r19131, this time with real Math:... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 6 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 | « base/gfx/png_decoder.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/webdata/web_database_unittest.cc
===================================================================
--- chrome/browser/webdata/web_database_unittest.cc (revision 19579)
+++ chrome/browser/webdata/web_database_unittest.cc (working copy)
@@ -641,8 +641,16 @@
image.setConfig(SkBitmap::kARGB_8888_Config, 16, 16);
image.allocPixels();
image.eraseColor(SK_ColorBLACK);
- // Some random pixels so that we can identify the image.
- *(reinterpret_cast<unsigned char*>(image.getPixels())) = 0xAB;
+
+ // Set some random pixels so that we can identify the image. We don't use
+ // transparent images because of pre-multiplication rounding errors.
+ SkColor test_pixel_1 = 0xffccbbaa;
+ SkColor test_pixel_2 = 0x00aabbaa;
+ SkColor test_pixel_3 = 0xff339966;
+ image.getAddr32(0, 1)[0] = test_pixel_1;
+ image.getAddr32(0, 1)[1] = test_pixel_2;
+ image.getAddr32(0, 1)[2] = test_pixel_3;
+
ASSERT_TRUE(db.SetWebAppImage(url, image));
images.clear();
ASSERT_TRUE(db.GetWebAppImages(url, &images));
@@ -650,10 +658,10 @@
ASSERT_EQ(16, images[0].width());
ASSERT_EQ(16, images[0].height());
images[0].lockPixels();
- unsigned char* pixels =
- reinterpret_cast<unsigned char*>(images[0].getPixels());
- ASSERT_TRUE(pixels != NULL);
- ASSERT_EQ(0xAB, *pixels);
+ ASSERT_TRUE(images[0].getPixels() != NULL);
+ ASSERT_EQ(test_pixel_1, images[0].getAddr32(0, 1)[0]);
+ ASSERT_EQ(test_pixel_2, images[0].getAddr32(0, 1)[1]);
+ ASSERT_EQ(test_pixel_3, images[0].getAddr32(0, 1)[2]);
images[0].unlockPixels();
// Add another image at a bigger size.
« no previous file with comments | « base/gfx/png_decoder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698