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

Side by Side Diff: components/favicon/core/favicon_handler_unittest.cc

Issue 1119163003: Save large icons to a new LARGE_ICON type Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: yet more clarifying comments Created 5 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/favicon/core/favicon_handler.h" 5 #include "components/favicon/core/favicon_handler.h"
6 6
7 #include<set> 7 #include<set>
8 #include<vector> 8 #include<vector>
9 9
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 bool update_active_favicon_; 299 bool update_active_favicon_;
300 300
301 DISALLOW_COPY_AND_ASSIGN(TestFaviconDriver); 301 DISALLOW_COPY_AND_ASSIGN(TestFaviconDriver);
302 }; 302 };
303 303
304 // This class is used to catch the FaviconHandler's download and history 304 // This class is used to catch the FaviconHandler's download and history
305 // request, and also provide the methods to access the FaviconHandler 305 // request, and also provide the methods to access the FaviconHandler
306 // internals. 306 // internals.
307 class TestFaviconHandler : public FaviconHandler { 307 class TestFaviconHandler : public FaviconHandler {
308 public: 308 public:
309 static int GetMaximalIconSize(favicon_base::IconType icon_type) { 309 using FaviconHandler::GetMaximalIconSize;
310 return FaviconHandler::GetMaximalIconSize(icon_type);
311 }
312 310
313 TestFaviconHandler(const GURL& page_url, 311 TestFaviconHandler(const GURL& page_url,
314 TestFaviconDriver* driver, 312 TestFaviconDriver* driver,
315 Type type, 313 Type type,
316 bool download_largest_icon) 314 bool download_largest_icon)
317 : FaviconHandler(nullptr, driver, type, download_largest_icon), 315 : FaviconHandler(nullptr, driver, type, download_largest_icon),
318 download_id_(0) { 316 download_id_(0) {
319 driver->SetActiveURL(page_url); 317 driver->SetActiveURL(page_url);
320 download_handler_.reset(new DownloadHandler(this)); 318 download_handler_.reset(new DownloadHandler(this));
321 } 319 }
(...skipping 1172 matching lines...) Expand 10 before | Expand all | Expand 10 after
1494 handler1.history_handler()->size_); 1492 handler1.history_handler()->size_);
1495 // Verify NotifyFaviconAvailable(). 1493 // Verify NotifyFaviconAvailable().
1496 EXPECT_FALSE(driver1.update_active_favicon()); 1494 EXPECT_FALSE(driver1.update_active_favicon());
1497 EXPECT_EQ(kSourceIconURLs[i].icon_url, driver1.available_icon_url()); 1495 EXPECT_EQ(kSourceIconURLs[i].icon_url, driver1.available_icon_url());
1498 EXPECT_EQ(kSourceIconURLs[i].icon_sizes[b], 1496 EXPECT_EQ(kSourceIconURLs[i].icon_sizes[b],
1499 driver1.available_favicon().Size()); 1497 driver1.available_favicon().Size());
1500 } 1498 }
1501 1499
1502 TEST_F(FaviconHandlerTest, TestFaviconWasScaledAfterDownload) { 1500 TEST_F(FaviconHandlerTest, TestFaviconWasScaledAfterDownload) {
1503 const GURL kPageURL("http://www.google.com"); 1501 const GURL kPageURL("http://www.google.com");
1504 const int kMaximalSize = 1502
1505 TestFaviconHandler::GetMaximalIconSize(favicon_base::FAVICON); 1503 TestFaviconDriver driver1;
1504 TestFaviconHandler handler1(kPageURL, &driver1, FaviconHandler::FAVICON,
1505 true);
1506 const int kMaximalSize = handler1.GetMaximalIconSize(favicon_base::FAVICON);
1506 1507
1507 std::vector<gfx::Size> icon1; 1508 std::vector<gfx::Size> icon1;
1508 icon1.push_back(gfx::Size(kMaximalSize + 1, kMaximalSize + 1)); 1509 icon1.push_back(gfx::Size(kMaximalSize + 1, kMaximalSize + 1));
1509 1510
1510 std::vector<gfx::Size> icon2; 1511 std::vector<gfx::Size> icon2;
1511 icon2.push_back(gfx::Size(kMaximalSize + 2, kMaximalSize + 2)); 1512 icon2.push_back(gfx::Size(kMaximalSize + 2, kMaximalSize + 2));
1512 1513
1513 const FaviconURL kSourceIconURLs[] = { 1514 const FaviconURL kSourceIconURLs[] = {
1514 FaviconURL( 1515 FaviconURL(
1515 GURL("http://www.google.com/b"), favicon_base::FAVICON, icon1), 1516 GURL("http://www.google.com/b"), favicon_base::FAVICON, icon1),
1516 FaviconURL( 1517 FaviconURL(
1517 GURL("http://www.google.com/c"), favicon_base::FAVICON, icon2)}; 1518 GURL("http://www.google.com/c"), favicon_base::FAVICON, icon2)};
1518 1519
1519 TestFaviconDriver driver1;
1520 TestFaviconHandler handler1(kPageURL, &driver1, FaviconHandler::FAVICON,
1521 true);
1522 std::vector<FaviconURL> urls1(kSourceIconURLs, 1520 std::vector<FaviconURL> urls1(kSourceIconURLs,
1523 kSourceIconURLs + arraysize(kSourceIconURLs)); 1521 kSourceIconURLs + arraysize(kSourceIconURLs));
1524 UpdateFaviconURL(&driver1, &handler1, kPageURL, urls1); 1522 UpdateFaviconURL(&driver1, &handler1, kPageURL, urls1);
1525 1523
1526 ASSERT_EQ(2u, handler1.urls().size()); 1524 ASSERT_EQ(2u, handler1.urls().size());
1527 1525
1528 // Index of largest favicon in kSourceIconURLs. 1526 // Index of largest favicon in kSourceIconURLs.
1529 size_t i = 1; 1527 size_t i = 1;
1530 // The largest bitmap's index in Favicon . 1528 // The largest bitmap's index in Favicon .
1531 int b = 0; 1529 int b = 0;
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
1705 EXPECT_FALSE(driver1.update_active_favicon()); 1703 EXPECT_FALSE(driver1.update_active_favicon());
1706 EXPECT_EQ(3u, driver1.num_favicon_available()); 1704 EXPECT_EQ(3u, driver1.num_favicon_available());
1707 } 1705 }
1708 1706
1709 INSTANTIATE_TEST_CASE_P(FaviconHandlerTestActiveFaviconValidityTrueOrFalse, 1707 INSTANTIATE_TEST_CASE_P(FaviconHandlerTestActiveFaviconValidityTrueOrFalse,
1710 FaviconHandlerActiveFaviconValidityParamTest, 1708 FaviconHandlerActiveFaviconValidityParamTest,
1711 ::testing::Bool()); 1709 ::testing::Bool());
1712 1710
1713 } // namespace 1711 } // namespace
1714 } // namespace favicon 1712 } // namespace favicon
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698