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

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

Issue 2796343003: Remove preferences among favicon types when choosing large icons
Patch Set: Rebased. Created 3 years, 8 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
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 4c03989081c5baeed60da5005933cd847be80ad7..bc2932f48fc2000399785bf784b33e14536681db 100644
--- a/components/history/core/browser/history_backend_unittest.cc
+++ b/components/history/core/browser/history_backend_unittest.cc
@@ -2805,102 +2805,23 @@ TEST_F(HistoryBackendTest, NoFaviconChangedNotifications) {
EXPECT_EQ(0u, favicon_changed_notifications_icon_urls().size());
}
-// Tests GetFaviconsForURL with icon_types priority,
-TEST_F(HistoryBackendTest, TestGetFaviconsForURLWithIconTypesPriority) {
- GURL page_url("http://www.google.com");
- GURL icon_url("http://www.google.com/favicon.ico");
- GURL touch_icon_url("http://wwww.google.com/touch_icon.ico");
-
- std::vector<SkBitmap> favicon_bitmaps;
- favicon_bitmaps.push_back(CreateBitmap(SK_ColorBLUE, 16));
- favicon_bitmaps.push_back(CreateBitmap(SK_ColorRED, 32));
-
- std::vector<SkBitmap> touch_bitmaps;
- touch_bitmaps.push_back(CreateBitmap(SK_ColorWHITE, 64));
-
- // Set some preexisting favicons for |page_url|.
- backend_->SetFavicons(
- page_url, favicon_base::FAVICON, icon_url, favicon_bitmaps);
- backend_->SetFavicons(
- page_url, favicon_base::TOUCH_ICON, touch_icon_url, touch_bitmaps);
-
- favicon_base::FaviconRawBitmapResult result;
- std::vector<int> icon_types;
- icon_types.push_back(favicon_base::FAVICON);
- icon_types.push_back(favicon_base::TOUCH_ICON);
-
- backend_->GetLargestFaviconForURL(page_url, icon_types, 16, &result);
-
- // Verify the result icon is 32x32 favicon.
- EXPECT_EQ(gfx::Size(32, 32), result.pixel_size);
- EXPECT_EQ(favicon_base::FAVICON, result.icon_type);
-
- // Change Minimal size to 32x32 and verify the 64x64 touch icon returned.
- backend_->GetLargestFaviconForURL(page_url, icon_types, 32, &result);
- EXPECT_EQ(gfx::Size(64, 64), result.pixel_size);
- EXPECT_EQ(favicon_base::TOUCH_ICON, result.icon_type);
-}
-
-// Test the the first types of icon is returned if its size equal to the
-// second types icon.
-TEST_F(HistoryBackendTest, TestGetFaviconsForURLReturnFavicon) {
- GURL page_url("http://www.google.com");
- GURL icon_url("http://www.google.com/favicon.ico");
- GURL touch_icon_url("http://wwww.google.com/touch_icon.ico");
-
- std::vector<SkBitmap> favicon_bitmaps;
- favicon_bitmaps.push_back(CreateBitmap(SK_ColorBLUE, 16));
- favicon_bitmaps.push_back(CreateBitmap(SK_ColorRED, 32));
-
- std::vector<SkBitmap> touch_bitmaps;
- touch_bitmaps.push_back(CreateBitmap(SK_ColorWHITE, 32));
-
- // Set some preexisting favicons for |page_url|.
- backend_->SetFavicons(
- page_url, favicon_base::FAVICON, icon_url, favicon_bitmaps);
- backend_->SetFavicons(
- page_url, favicon_base::TOUCH_ICON, touch_icon_url, touch_bitmaps);
-
- favicon_base::FaviconRawBitmapResult result;
- std::vector<int> icon_types;
- icon_types.push_back(favicon_base::FAVICON);
- icon_types.push_back(favicon_base::TOUCH_ICON);
-
- backend_->GetLargestFaviconForURL(page_url, icon_types, 16, &result);
-
- // Verify the result icon is 32x32 favicon.
- EXPECT_EQ(gfx::Size(32, 32), result.pixel_size);
- EXPECT_EQ(favicon_base::FAVICON, result.icon_type);
-
- // Change minimal size to 32x32 and verify the 32x32 favicon returned.
- favicon_base::FaviconRawBitmapResult result1;
- backend_->GetLargestFaviconForURL(page_url, icon_types, 32, &result1);
- EXPECT_EQ(gfx::Size(32, 32), result1.pixel_size);
- EXPECT_EQ(favicon_base::FAVICON, result1.icon_type);
-}
-
// Test the favicon is returned if its size is smaller than minimal size,
// because it is only one available.
-TEST_F(HistoryBackendTest, TestGetFaviconsForURLReturnFaviconEvenItSmaller) {
+TEST_F(HistoryBackendTest, TestGetLargestFaviconsForURL) {
GURL page_url("http://www.google.com");
GURL icon_url("http://www.google.com/favicon.ico");
-
- std::vector<SkBitmap> bitmaps;
- bitmaps.push_back(CreateBitmap(SK_ColorBLUE, 16));
+ GURL touch_icon_url("http://wwww.google.com/touch_icon.ico");
// Set preexisting favicons for |page_url|.
- backend_->SetFavicons(page_url, favicon_base::FAVICON, icon_url, bitmaps);
+ backend_->SetFavicons(page_url, favicon_base::FAVICON, icon_url,
+ {CreateBitmap(SK_ColorBLUE, 16)});
+ backend_->SetFavicons(page_url, favicon_base::TOUCH_ICON, touch_icon_url,
+ {CreateBitmap(SK_ColorGREEN, 64)});
favicon_base::FaviconRawBitmapResult result;
- std::vector<int> icon_types;
- icon_types.push_back(favicon_base::FAVICON);
- icon_types.push_back(favicon_base::TOUCH_ICON);
-
- backend_->GetLargestFaviconForURL(page_url, icon_types, 32, &result);
-
- // Verify 16x16 icon is returned, even it small than minimal_size.
- EXPECT_EQ(gfx::Size(16, 16), result.pixel_size);
- EXPECT_EQ(favicon_base::FAVICON, result.icon_type);
+ backend_->GetLargestFaviconForURL(page_url, &result);
+ EXPECT_EQ(gfx::Size(64, 64), result.pixel_size);
+ EXPECT_EQ(favicon_base::TOUCH_ICON, result.icon_type);
}
// Test UpdateFaviconMappingsAndFetch() when multiple icon types are passed in.
« no previous file with comments | « components/history/core/browser/history_backend.cc ('k') | components/history/core/browser/history_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698