| Index: chrome/browser/history/history_backend_unittest.cc
|
| diff --git a/chrome/browser/history/history_backend_unittest.cc b/chrome/browser/history/history_backend_unittest.cc
|
| index 04af2b41ffb87c4efc6d29b5292d1814a06a4134..96754dc36388de369cdf3557d5f30b60499258d9 100644
|
| --- a/chrome/browser/history/history_backend_unittest.cc
|
| +++ b/chrome/browser/history/history_backend_unittest.cc
|
| @@ -1911,8 +1911,10 @@ TEST_F(HistoryBackendTest, MergeFaviconShowsUpInGetFaviconsForURLResult) {
|
| // Request favicon bitmaps for both 1x and 2x to simulate request done by
|
| // BookmarkModel::GetFavicon().
|
| std::vector<chrome::FaviconBitmapResult> bitmap_results;
|
| - backend_->GetFaviconsForURL(page_url, chrome::FAVICON, kSmallSize.width(),
|
| - GetScaleFactors1x2x(), &bitmap_results);
|
| + std::vector<int> icon_types_priority;
|
| + icon_types_priority.push_back(chrome::FAVICON);
|
| + backend_->GetFaviconsForURL(page_url, icon_types_priority, kSmallSize.width(),
|
| + GetScaleFactors1x2x(), 0, &bitmap_results);
|
|
|
| EXPECT_EQ(2u, bitmap_results.size());
|
| const chrome::FaviconBitmapResult& first_result = bitmap_results[0];
|
| @@ -1922,6 +1924,131 @@ TEST_F(HistoryBackendTest, MergeFaviconShowsUpInGetFaviconsForURLResult) {
|
| EXPECT_TRUE(BitmapDataEqual('c', result.bitmap_data));
|
| }
|
|
|
| +// 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<chrome::FaviconBitmapData> favicon_bitmap_data;
|
| + std::vector<gfx::Size> favicon_size;
|
| + favicon_size.push_back(gfx::Size(16, 16));
|
| + favicon_size.push_back(gfx::Size(32, 32));
|
| + GenerateFaviconBitmapData(icon_url, favicon_size, &favicon_bitmap_data);
|
| + ASSERT_EQ(2u, favicon_bitmap_data.size());
|
| +
|
| + std::vector<chrome::FaviconBitmapData> touch_icon_bitmap_data;
|
| + std::vector<gfx::Size> touch_icon_size;
|
| + touch_icon_size.push_back(gfx::Size(64, 64));
|
| + GenerateFaviconBitmapData(icon_url, touch_icon_size, &touch_icon_bitmap_data);
|
| + ASSERT_EQ(1u, touch_icon_bitmap_data.size());
|
| +
|
| + // Set some preexisting favicons for |page_url|.
|
| + backend_->SetFavicons(page_url, chrome::FAVICON, favicon_bitmap_data);
|
| + backend_->SetFavicons(page_url, chrome::TOUCH_ICON, touch_icon_bitmap_data);
|
| +
|
| + std::vector<chrome::FaviconBitmapResult> bitmap_results;
|
| + std::vector<int> icon_types_priority;
|
| + icon_types_priority.push_back(chrome::FAVICON);
|
| + icon_types_priority.push_back(chrome::TOUCH_ICON);
|
| +
|
| + backend_->GetFaviconsForURL(page_url, icon_types_priority, kSmallSize.width(),
|
| + GetScaleFactors1x2x(), 16, &bitmap_results);
|
| +
|
| + // Verify the result icon is 32x32 favicon.
|
| + EXPECT_EQ(1u, bitmap_results.size());
|
| + chrome::FaviconBitmapResult& result = bitmap_results[0];
|
| + EXPECT_EQ(gfx::Size(32, 32), result.pixel_size);
|
| + EXPECT_EQ(chrome::FAVICON, result.icon_type);
|
| +
|
| + // Change Minimal size to 32x32 and verify the 64x64 touch icon returned.
|
| + bitmap_results.clear();
|
| + backend_->GetFaviconsForURL(page_url, icon_types_priority, kSmallSize.width(),
|
| + GetScaleFactors1x2x(), 32, &bitmap_results);
|
| + EXPECT_EQ(1u, bitmap_results.size());
|
| + result = bitmap_results[0];
|
| + EXPECT_EQ(gfx::Size(64, 64), result.pixel_size);
|
| + EXPECT_EQ(chrome::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<chrome::FaviconBitmapData> favicon_bitmap_data;
|
| + std::vector<gfx::Size> favicon_size;
|
| + favicon_size.push_back(gfx::Size(16, 16));
|
| + favicon_size.push_back(gfx::Size(32, 32));
|
| + GenerateFaviconBitmapData(icon_url, favicon_size, &favicon_bitmap_data);
|
| + ASSERT_EQ(2u, favicon_bitmap_data.size());
|
| +
|
| + std::vector<chrome::FaviconBitmapData> touch_icon_bitmap_data;
|
| + std::vector<gfx::Size> touch_icon_size;
|
| + touch_icon_size.push_back(gfx::Size(32, 32));
|
| + GenerateFaviconBitmapData(icon_url, touch_icon_size, &touch_icon_bitmap_data);
|
| + ASSERT_EQ(1u, touch_icon_bitmap_data.size());
|
| +
|
| + // Set some preexisting favicons for |page_url|.
|
| + backend_->SetFavicons(page_url, chrome::FAVICON, favicon_bitmap_data);
|
| + backend_->SetFavicons(page_url, chrome::TOUCH_ICON, touch_icon_bitmap_data);
|
| +
|
| + std::vector<chrome::FaviconBitmapResult> bitmap_results;
|
| + std::vector<int> icon_types_priority;
|
| + icon_types_priority.push_back(chrome::FAVICON);
|
| + icon_types_priority.push_back(chrome::TOUCH_ICON);
|
| +
|
| + backend_->GetFaviconsForURL(page_url, icon_types_priority, kSmallSize.width(),
|
| + GetScaleFactors1x2x(), 16, &bitmap_results);
|
| +
|
| + // Verify the result icon is 32x32 favicon.
|
| + EXPECT_EQ(1u, bitmap_results.size());
|
| + chrome::FaviconBitmapResult& result = bitmap_results[0];
|
| + EXPECT_EQ(gfx::Size(32, 32), result.pixel_size);
|
| + EXPECT_EQ(chrome::FAVICON, result.icon_type);
|
| +
|
| + // Change minimal size to 32x32 and verify the 32x32 favicon returned.
|
| + bitmap_results.clear();
|
| + backend_->GetFaviconsForURL(page_url, icon_types_priority, kSmallSize.width(),
|
| + GetScaleFactors1x2x(), 32, &bitmap_results);
|
| + EXPECT_EQ(1u, bitmap_results.size());
|
| + result = bitmap_results[0];
|
| + EXPECT_EQ(gfx::Size(32, 32), result.pixel_size);
|
| + EXPECT_EQ(chrome::FAVICON, result.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) {
|
| + GURL page_url("http://www.google.com");
|
| + GURL icon_url("http://www.google.com/favicon.ico");
|
| +
|
| + std::vector<chrome::FaviconBitmapData> favicon_bitmap_data;
|
| + std::vector<gfx::Size> favicon_size;
|
| + favicon_size.push_back(gfx::Size(16, 16));
|
| + GenerateFaviconBitmapData(icon_url, favicon_size, &favicon_bitmap_data);
|
| + ASSERT_EQ(1u, favicon_bitmap_data.size());
|
| +
|
| + // Set preexisting favicons for |page_url|.
|
| + backend_->SetFavicons(page_url, chrome::FAVICON, favicon_bitmap_data);
|
| +
|
| + std::vector<chrome::FaviconBitmapResult> bitmap_results;
|
| + std::vector<int> icon_types_priority;
|
| + icon_types_priority.push_back(chrome::FAVICON);
|
| + icon_types_priority.push_back(chrome::TOUCH_ICON);
|
| +
|
| + backend_->GetFaviconsForURL(page_url, icon_types_priority, kSmallSize.width(),
|
| + GetScaleFactors1x2x(), 32, &bitmap_results);
|
| +
|
| + // Verify 16x16 icon is returned, even it small than minimal_size.
|
| + EXPECT_EQ(1u, bitmap_results.size());
|
| + chrome::FaviconBitmapResult& result = bitmap_results[0];
|
| + EXPECT_EQ(gfx::Size(16, 16), result.pixel_size);
|
| + EXPECT_EQ(chrome::FAVICON, result.icon_type);
|
| +}
|
| +
|
| // Test UpdateFaviconMapingsAndFetch() when multiple icon types are passed in.
|
| TEST_F(HistoryBackendTest, UpdateFaviconMappingsAndFetchMultipleIconTypes) {
|
| GURL page_url1("http://www.google.com");
|
|
|