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

Unified Diff: components/history/core/browser/history_backend_unittest.cc

Issue 1128343004: Allow favicons for synced bookmarks to expire (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 | « components/history/core/browser/history_backend.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/history/core/browser/history_backend_unittest.cc
diff --git a/components/history/core/browser/history_backend_unittest.cc b/components/history/core/browser/history_backend_unittest.cc
index d16e89d513b6166a8f951b2da0bec9ca93ae9f76..7858646813cfe41002bb45d5132337ecbd4497aa 100644
--- a/components/history/core/browser/history_backend_unittest.cc
+++ b/components/history/core/browser/history_backend_unittest.cc
@@ -2324,6 +2324,56 @@ TEST_F(HistoryBackendTest, MergeFaviconShowsUpInGetFaviconsForURLResult) {
EXPECT_TRUE(BitmapDataEqual('c', result.bitmap_data));
}
+// Tests that calling MergeFavicon() with identical favicon data does not affect
+// the favicon bitmap's "last updated" time. This is important because sync
+// calls MergeFavicon() for all of the favicons that it manages at startup.
+TEST_F(HistoryBackendTest, MergeIdenticalFaviconDoesNotChangeLastUpdatedTime) {
+ GURL page_url("http://www.google.com");
+ GURL icon_url("http://www.google.com/favicon.ico");
+ std::vector<unsigned char> data;
+ data.push_back('a');
+
+ scoped_refptr<base::RefCountedBytes> bitmap_data(
+ new base::RefCountedBytes(data));
+ backend_->MergeFavicon(page_url,
+ icon_url,
+ favicon_base::FAVICON,
+ bitmap_data,
+ kSmallSize);
+
+ // Find the ID of the add favicon bitmap.
+ std::vector<IconMapping> icon_mappings;
+ ASSERT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL(page_url,
+ &icon_mappings));
+ ASSERT_EQ(1u, icon_mappings.size());
+ std::vector<FaviconBitmap> favicon_bitmaps;
+ ASSERT_TRUE(backend_->thumbnail_db_->GetFaviconBitmaps(
+ icon_mappings[0].icon_id, &favicon_bitmaps));
+
+ // Change the last updated time of the just added favicon bitmap.
+ const base::Time kLastUpdateTime =
+ base::Time::Now() - base::TimeDelta::FromDays(314);
+ backend_->thumbnail_db_->SetFaviconBitmapLastUpdateTime(
+ favicon_bitmaps[0].bitmap_id, kLastUpdateTime);
+
+ // Call MergeFavicon() with identical data.
+ backend_->MergeFavicon(page_url,
+ icon_url,
+ favicon_base::FAVICON,
+ bitmap_data,
+ kSmallSize);
+
+ // Check that the "last updated" time did not change.
+ icon_mappings.clear();
+ ASSERT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL(page_url,
+ &icon_mappings));
+ ASSERT_EQ(1u, icon_mappings.size());
+ favicon_bitmaps.clear();
+ ASSERT_TRUE(backend_->thumbnail_db_->GetFaviconBitmaps(
+ icon_mappings[0].icon_id, &favicon_bitmaps));
+ EXPECT_EQ(kLastUpdateTime, favicon_bitmaps[0].last_updated);
+}
+
// Tests GetFaviconsForURL with icon_types priority,
TEST_F(HistoryBackendTest, TestGetFaviconsForURLWithIconTypesPriority) {
GURL page_url("http://www.google.com");
« no previous file with comments | « components/history/core/browser/history_backend.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698