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

Unified Diff: chrome/browser/history/top_sites_unittest.cc

Issue 3135035: Fix broken thumbnails for sites with redirects. (Closed)
Patch Set: Comment. Created 10 years, 4 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 | « chrome/browser/history/top_sites.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/history/top_sites_unittest.cc
diff --git a/chrome/browser/history/top_sites_unittest.cc b/chrome/browser/history/top_sites_unittest.cc
index d0ab05f097c1eb85d8f29c9341b8ee7648fc69dd..360cd0d543d63e2b5c59adc6c9c96a74b5c7f5f1 100644
--- a/chrome/browser/history/top_sites_unittest.cc
+++ b/chrome/browser/history/top_sites_unittest.cc
@@ -415,6 +415,50 @@ TEST_F(TopSitesTest, SetPageThumbnail) {
EXPECT_FALSE(top_sites().SetPageThumbnail(url1a, thumbnail, medium_score));
}
+TEST_F(TopSitesTest, GetPageThumbnail) {
+ ChromeThread db_loop(ChromeThread::DB, MessageLoop::current());
+ MostVisitedURLList url_list;
+ MostVisitedURL url1 = {GURL("http://asdf.com")};
+ url1.redirects.push_back(url1.url);
+ url_list.push_back(url1);
+
+ MostVisitedURL url2 = {GURL("http://gmail.com")};
+ url2.redirects.push_back(url2.url);
+ url2.redirects.push_back(GURL("http://mail.google.com"));
+ url_list.push_back(url2);
+
+ top_sites().UpdateMostVisited(url_list);
+ MessageLoop::current()->RunAllPending();
+
+ // Create a dummy thumbnail.
+ SkBitmap thumbnail;
+ thumbnail.setConfig(SkBitmap::kARGB_8888_Config, 4, 4);
+ thumbnail.allocPixels();
+ thumbnail.eraseRGB(0x00, 0x00, 0x00);
+ ThumbnailScore score(0.5, true, true, base::Time::Now());
+
+ RefCountedBytes* result = NULL;
+ EXPECT_TRUE(top_sites().SetPageThumbnail(url1.url, thumbnail, score));
+ EXPECT_TRUE(top_sites().GetPageThumbnail(url1.url, &result));
+
+ EXPECT_TRUE(top_sites().SetPageThumbnail(GURL("http://gmail.com"),
+ thumbnail, score));
+ EXPECT_TRUE(top_sites().GetPageThumbnail(GURL("http://gmail.com"),
+ &result));
+ // Get a thumbnail via a redirect.
+ EXPECT_TRUE(top_sites().GetPageThumbnail(GURL("http://mail.google.com"),
+ &result));
+
+ EXPECT_TRUE(top_sites().SetPageThumbnail(GURL("http://mail.google.com"),
+ thumbnail, score));
+ EXPECT_TRUE(top_sites().GetPageThumbnail(url2.url, &result));
+
+ scoped_ptr<SkBitmap> out_bitmap(gfx::JPEGCodec::Decode(result->front(),
+ result->size()));
+ EXPECT_EQ(0, memcmp(thumbnail.getPixels(), out_bitmap->getPixels(),
+ thumbnail.getSize()));
+}
+
TEST_F(TopSitesTest, GetMostVisited) {
ChromeThread db_loop(ChromeThread::DB, MessageLoop::current());
GURL news("http://news.google.com/");
« no previous file with comments | « chrome/browser/history/top_sites.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698