Chromium Code Reviews| 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"))); |
|
pkotwicz
2017/03/27 00:49:06
Can't you just swap FaviconHandler::image_urls() f
mastiz
2017/03/27 10:09:36
No, because we don't have size information. And I
pkotwicz
2017/03/27 19:12:44
Ok I see now.
Can you name each of the FaviconURL
mastiz
2017/03/28 09:09:30
This was done, but I had failed to export the chan
|
| } |
| 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 |