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

Unified Diff: components/favicon/core/favicon_handler_unittest.cc

Issue 2739173002: Always select best favicon bitmap (Closed)
Patch Set: Minor changes. Created 3 years, 9 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/favicon/core/favicon_handler_unittest.cc
diff --git a/components/favicon/core/favicon_handler_unittest.cc b/components/favicon/core/favicon_handler_unittest.cc
index 5cbe691f441020857267ecfeac8505a508e94c74..71fd9af1a864b179d2feb1645d94127b782335a3 100644
--- a/components/favicon/core/favicon_handler_unittest.cc
+++ b/components/favicon/core/favicon_handler_unittest.cc
@@ -901,32 +901,17 @@ TEST_F(FaviconHandlerTest, TestSortFavicon) {
std::unique_ptr<FaviconHandler> handler = RunHandlerWithCandidates(
FaviconDriverObserver::NON_TOUCH_LARGEST, kSourceIconURLs);
- struct ExpectedResult {
- // The favicon's index in kSourceIconURLs.
- size_t favicon_index;
- // Width of largest bitmap.
- int width;
- } results[] = {
- // First is icon2, though its size larger than maximal.
- {1, 1024},
- // Second is icon1
- // The 17x17 is largest.
- {0, 17},
- // Third is icon3.
- // The 16x16 is largest.
- {2, 16},
- // The rest of bitmaps come in order, there is no "sizes" attribute.
- {3, -1},
- {4, -1},
- };
- const std::vector<FaviconURL>& icons = handler->image_urls();
- ASSERT_EQ(5u, icons.size());
- for (size_t i = 0; i < icons.size(); ++i) {
- EXPECT_EQ(kSourceIconURLs[results[i].favicon_index].icon_url,
- icons[i].icon_url);
- if (results[i].width != -1)
- EXPECT_EQ(results[i].width, icons[i].icon_sizes[0].width());
- }
+ EXPECT_THAT(
+ handler->GetIconURLs(),
+ ElementsAre(
+ // First is icon2, though its size larger than maximal.
+ GURL("http://www.google.com/b"),
+ // Second is icon1.
+ GURL("http://www.google.com/a"),
+ // Third is icon3.
+ GURL("http://www.google.com/c"),
+ // The rest of bitmaps come in order, there is no "sizes" attribute.
+ GURL("http://www.google.com/d"), GURL("http://www.google.com/e")));
}
TEST_F(FaviconHandlerTest, TestDownloadLargestFavicon) {
@@ -979,7 +964,8 @@ TEST_F(FaviconHandlerTest, TestSelectLargestFavicon) {
}
TEST_F(FaviconHandlerTest, TestFaviconWasScaledAfterDownload) {
- const int kMaximalSize = FaviconHandler::GetMaximalIconSize(FAVICON);
+ const int kMaximalSize = FaviconHandler::GetMaximalIconSize(
+ FaviconDriverObserver::NON_TOUCH_LARGEST);
const GURL kIconURL1("http://www.google.com/b");
const GURL kIconURL2("http://www.google.com/c");
@@ -992,10 +978,10 @@ TEST_F(FaviconHandlerTest, TestFaviconWasScaledAfterDownload) {
delegate_.fake_downloader().AddWithOriginalSizes(
kIconURL2, IntVector{kMaximalSize}, IntVector{kOriginalSize2});
- // Verify the largest bitmap was selected although it was scaled down to
- // maximal size and smaller than |kIconURL1| now.
+ // Verify the best bitmap was selected (although smaller than |kIconURL2|)
+ // and that it was scaled down to |kMaximalSize|.
EXPECT_CALL(delegate_,
- OnFaviconUpdated(_, _, kIconURL2, _,
+ OnFaviconUpdated(_, _, kIconURL1, _,
ImageSizeIs(kMaximalSize, kMaximalSize)));
RunHandlerWithCandidates(
@@ -1005,7 +991,7 @@ TEST_F(FaviconHandlerTest, TestFaviconWasScaledAfterDownload) {
FaviconURL(kIconURL2, FAVICON,
SizeVector{gfx::Size(kOriginalSize2, kOriginalSize2)})});
- EXPECT_THAT(delegate_.downloads(), ElementsAre(kIconURL2));
+ EXPECT_THAT(delegate_.downloads(), ElementsAre(kIconURL1));
}
// Test that if several icons are downloaded because the icons are smaller than

Powered by Google App Engine
This is Rietveld 408576698