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

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

Issue 2823093002: Make FaviconService::GetRawFaviconForPageURL() select the best candidate among all the icon types (Closed)
Patch Set: Merge branch 'master' into icon_type Created 3 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/favicon/core/favicon_service.h ('k') | components/history/core/browser/history_service.h » ('j') | 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 9a72cb5706005afd445fd69e524128647de51577..48cee5bf8d9c4a2d877b37456fde6833b6678d09 100644
--- a/components/history/core/browser/history_backend_unittest.cc
+++ b/components/history/core/browser/history_backend_unittest.cc
@@ -2993,6 +2993,35 @@ TEST_F(HistoryBackendTest, GetFaviconsFromDBIconType) {
EXPECT_EQ(icon_url2, bitmap_results_out[0].icon_url);
}
+// Test that when GetFaviconsFromDB() is called with multiple icon types that
+// the best favicon bitmap is selected from among all of the icon types.
+TEST_F(HistoryBackendTest, GetFaviconsFromDBMultipleIconTypes) {
+ const GURL page_url("http://www.google.com/");
+ const GURL icon_url1("http://www.google.com/icon1.png");
+ const GURL icon_url2("http://www.google.com/icon2.png");
+
+ std::vector<favicon_base::FaviconRawBitmapData> favicon_bitmap_data;
+ backend_->SetFavicons(page_url, favicon_base::FAVICON, icon_url1,
+ {CreateBitmap(SK_ColorBLUE, kSmallEdgeSize)});
+ backend_->SetFavicons(page_url, favicon_base::TOUCH_ICON, icon_url2,
+ {CreateBitmap(SK_ColorBLUE, kLargeEdgeSize)});
+
+ struct TestCase {
+ int desired_edge_size;
+ GURL expected_icon_url;
+ } kTestCases[]{{kSmallEdgeSize, icon_url1}, {kLargeEdgeSize, icon_url2}};
+
+ for (const TestCase& test_case : kTestCases) {
+ std::vector<favicon_base::FaviconRawBitmapResult> bitmap_results_out;
+ backend_->GetFaviconsForURL(
+ page_url, favicon_base::FAVICON | favicon_base::TOUCH_ICON,
+ {test_case.desired_edge_size}, &bitmap_results_out);
+
+ ASSERT_EQ(1u, bitmap_results_out.size());
+ EXPECT_EQ(test_case.expected_icon_url, bitmap_results_out[0].icon_url);
+ }
+}
+
// Test that GetFaviconsFromDB() correctly sets the expired flag for bitmap
// reults.
TEST_F(HistoryBackendTest, GetFaviconsFromDBExpired) {
« no previous file with comments | « components/favicon/core/favicon_service.h ('k') | components/history/core/browser/history_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698