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

Side by Side Diff: chrome/browser/webdata/web_database_unittest.cc

Issue 155226: Merge 19589 - Reland of r19131, this time with real Math:... (Closed) Base URL: svn://chrome-svn/chrome/branches/191/src/
Patch Set: Created 11 years, 5 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 | « base/gfx/png_decoder.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:mergeinfo
Merged /trunk/src/chrome/browser/webdata/web_database_unittest.cc:r19589
Merged /branches/chrome_webkit_merge_branch/chrome/browser/webdata/web_database_unittest.cc:r69-2775
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/file_util.h" 5 #include "base/file_util.h"
6 #include "base/path_service.h" 6 #include "base/path_service.h"
7 #include "base/stl_util-inl.h" 7 #include "base/stl_util-inl.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/time.h" 9 #include "base/time.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 // Make sure we get the image back. 634 // Make sure we get the image back.
635 ASSERT_TRUE(db.GetWebAppImages(url, &images)); 635 ASSERT_TRUE(db.GetWebAppImages(url, &images));
636 ASSERT_EQ(1U, images.size()); 636 ASSERT_EQ(1U, images.size());
637 ASSERT_EQ(16, images[0].width()); 637 ASSERT_EQ(16, images[0].width());
638 ASSERT_EQ(16, images[0].height()); 638 ASSERT_EQ(16, images[0].height());
639 639
640 // Add another 16x16 image and make sure it replaces the original. 640 // Add another 16x16 image and make sure it replaces the original.
641 image.setConfig(SkBitmap::kARGB_8888_Config, 16, 16); 641 image.setConfig(SkBitmap::kARGB_8888_Config, 16, 16);
642 image.allocPixels(); 642 image.allocPixels();
643 image.eraseColor(SK_ColorBLACK); 643 image.eraseColor(SK_ColorBLACK);
644 // Some random pixels so that we can identify the image. 644
645 *(reinterpret_cast<unsigned char*>(image.getPixels())) = 0xAB; 645 // Set some random pixels so that we can identify the image. We don't use
646 // transparent images because of pre-multiplication rounding errors.
647 SkColor test_pixel_1 = 0xffccbbaa;
648 SkColor test_pixel_2 = 0x00aabbaa;
649 SkColor test_pixel_3 = 0xff339966;
650 image.getAddr32(0, 1)[0] = test_pixel_1;
651 image.getAddr32(0, 1)[1] = test_pixel_2;
652 image.getAddr32(0, 1)[2] = test_pixel_3;
653
646 ASSERT_TRUE(db.SetWebAppImage(url, image)); 654 ASSERT_TRUE(db.SetWebAppImage(url, image));
647 images.clear(); 655 images.clear();
648 ASSERT_TRUE(db.GetWebAppImages(url, &images)); 656 ASSERT_TRUE(db.GetWebAppImages(url, &images));
649 ASSERT_EQ(1U, images.size()); 657 ASSERT_EQ(1U, images.size());
650 ASSERT_EQ(16, images[0].width()); 658 ASSERT_EQ(16, images[0].width());
651 ASSERT_EQ(16, images[0].height()); 659 ASSERT_EQ(16, images[0].height());
652 images[0].lockPixels(); 660 images[0].lockPixels();
653 unsigned char* pixels = 661 ASSERT_TRUE(images[0].getPixels() != NULL);
654 reinterpret_cast<unsigned char*>(images[0].getPixels()); 662 ASSERT_EQ(test_pixel_1, images[0].getAddr32(0, 1)[0]);
655 ASSERT_TRUE(pixels != NULL); 663 ASSERT_EQ(test_pixel_2, images[0].getAddr32(0, 1)[1]);
656 ASSERT_EQ(0xAB, *pixels); 664 ASSERT_EQ(test_pixel_3, images[0].getAddr32(0, 1)[2]);
657 images[0].unlockPixels(); 665 images[0].unlockPixels();
658 666
659 // Add another image at a bigger size. 667 // Add another image at a bigger size.
660 image.setConfig(SkBitmap::kARGB_8888_Config, 32, 32); 668 image.setConfig(SkBitmap::kARGB_8888_Config, 32, 32);
661 image.allocPixels(); 669 image.allocPixels();
662 image.eraseColor(SK_ColorBLACK); 670 image.eraseColor(SK_ColorBLACK);
663 ASSERT_TRUE(db.SetWebAppImage(url, image)); 671 ASSERT_TRUE(db.SetWebAppImage(url, image));
664 672
665 // Make sure we get both images back. 673 // Make sure we get both images back.
666 images.clear(); 674 images.clear();
667 ASSERT_TRUE(db.GetWebAppImages(url, &images)); 675 ASSERT_TRUE(db.GetWebAppImages(url, &images));
668 ASSERT_EQ(2U, images.size()); 676 ASSERT_EQ(2U, images.size());
669 if (images[0].width() == 16) { 677 if (images[0].width() == 16) {
670 ASSERT_EQ(16, images[0].width()); 678 ASSERT_EQ(16, images[0].width());
671 ASSERT_EQ(16, images[0].height()); 679 ASSERT_EQ(16, images[0].height());
672 ASSERT_EQ(32, images[1].width()); 680 ASSERT_EQ(32, images[1].width());
673 ASSERT_EQ(32, images[1].height()); 681 ASSERT_EQ(32, images[1].height());
674 } else { 682 } else {
675 ASSERT_EQ(32, images[0].width()); 683 ASSERT_EQ(32, images[0].width());
676 ASSERT_EQ(32, images[0].height()); 684 ASSERT_EQ(32, images[0].height());
677 ASSERT_EQ(16, images[1].width()); 685 ASSERT_EQ(16, images[1].width());
678 ASSERT_EQ(16, images[1].height()); 686 ASSERT_EQ(16, images[1].height());
679 } 687 }
680 } 688 }
OLDNEW
« 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