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

Unified Diff: chrome/browser/favicon/favicon_handler_unittest.cc

Issue 227153007: Remove dependency on Profile's IsOffTheRecord in favicon_handler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@FAVICON_create_core_dir
Patch Set: Review fixes. Created 6 years, 8 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: chrome/browser/favicon/favicon_handler_unittest.cc
diff --git a/chrome/browser/favicon/favicon_handler_unittest.cc b/chrome/browser/favicon/favicon_handler_unittest.cc
index 1e3456b0cf4ce81bb40a32aa0f03faf71706e92d..b844055a332a0d1efe50aabc867bbaef5b31de3d 100644
--- a/chrome/browser/favicon/favicon_handler_unittest.cc
+++ b/chrome/browser/favicon/favicon_handler_unittest.cc
@@ -8,6 +8,7 @@
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/test/base/chrome_render_view_host_test_harness.h"
+#include "components/favicon/content/browser/content_favicon_driver.h"
#include "content/public/browser/favicon_status.h"
#include "content/public/browser/invalidate_type.h"
#include "content/public/browser/navigation_entry.h"
@@ -167,6 +168,9 @@ class HistoryRequestHandler {
} // namespace
+class TestFaviconDriver : public FaviconDriver {
+ virtual bool IsOffTheRecord() OVERRIDE { return false; }
+};
class TestFaviconHandlerDelegate : public FaviconHandlerDelegate {
public:
@@ -205,9 +209,10 @@ class TestFaviconHandler : public FaviconHandler {
public:
TestFaviconHandler(const GURL& page_url,
Profile* profile,
+ FaviconDriver* driver,
FaviconHandlerDelegate* delegate,
Type type)
- : FaviconHandler(profile, delegate, type),
+ : FaviconHandler(profile, driver, delegate, type),
entry_(NavigationEntry::Create()),
download_id_(0),
num_favicon_updates_(0) {
@@ -437,10 +442,11 @@ TEST_F(FaviconHandlerTest, GetFaviconFromHistory) {
const GURL icon_url("http://www.google.com/favicon");
TestFaviconHandlerDelegate delegate;
+ TestFaviconDriver driver;
Profile* profile = Profile::FromBrowserContext(
web_contents()->GetBrowserContext());
- TestFaviconHandler helper(page_url, profile,
- &delegate, FaviconHandler::FAVICON);
+ TestFaviconHandler helper(
+ page_url, profile, &driver, &delegate, FaviconHandler::FAVICON);
helper.FetchFavicon(page_url);
HistoryRequestHandler* history_handler = helper.history_handler();
@@ -479,10 +485,11 @@ TEST_F(FaviconHandlerTest, DownloadFavicon) {
const GURL icon_url("http://www.google.com/favicon");
TestFaviconHandlerDelegate delegate;
+ TestFaviconDriver driver;
Profile* profile = Profile::FromBrowserContext(
web_contents()->GetBrowserContext());
- TestFaviconHandler helper(page_url, profile,
- &delegate, FaviconHandler::FAVICON);
+ TestFaviconHandler helper(
+ page_url, profile, &driver, &delegate, FaviconHandler::FAVICON);
helper.FetchFavicon(page_url);
HistoryRequestHandler* history_handler = helper.history_handler();
@@ -548,10 +555,11 @@ TEST_F(FaviconHandlerTest, UpdateAndDownloadFavicon) {
const GURL new_icon_url("http://www.google.com/new_favicon");
TestFaviconHandlerDelegate delegate;
+ TestFaviconDriver driver;
Profile* profile = Profile::FromBrowserContext(
web_contents()->GetBrowserContext());
- TestFaviconHandler helper(page_url, profile,
- &delegate, FaviconHandler::FAVICON);
+ TestFaviconHandler helper(
+ page_url, profile, &driver, &delegate, FaviconHandler::FAVICON);
helper.FetchFavicon(page_url);
HistoryRequestHandler* history_handler = helper.history_handler();
@@ -631,10 +639,11 @@ TEST_F(FaviconHandlerTest, FaviconInHistoryInvalid) {
const GURL icon_url("http://www.google.com/favicon");
TestFaviconHandlerDelegate delegate;
+ TestFaviconDriver driver;
Profile* profile = Profile::FromBrowserContext(
web_contents()->GetBrowserContext());
- TestFaviconHandler helper(page_url, profile,
- &delegate, FaviconHandler::FAVICON);
+ TestFaviconHandler helper(
+ page_url, profile, &driver, &delegate, FaviconHandler::FAVICON);
helper.FetchFavicon(page_url);
HistoryRequestHandler* history_handler = helper.history_handler();
@@ -705,10 +714,11 @@ TEST_F(FaviconHandlerTest, UpdateFavicon) {
const GURL new_icon_url("http://www.google.com/new_favicon");
TestFaviconHandlerDelegate delegate;
+ TestFaviconDriver driver;
Profile* profile = Profile::FromBrowserContext(
web_contents()->GetBrowserContext());
- TestFaviconHandler helper(page_url, profile,
- &delegate, FaviconHandler::FAVICON);
+ TestFaviconHandler helper(
+ page_url, profile, &driver, &delegate, FaviconHandler::FAVICON);
helper.FetchFavicon(page_url);
HistoryRequestHandler* history_handler = helper.history_handler();
@@ -768,10 +778,11 @@ TEST_F(FaviconHandlerTest, Download2ndFaviconURLCandidate) {
const GURL new_icon_url("http://www.google.com/new_favicon");
TestFaviconHandlerDelegate delegate;
+ TestFaviconDriver driver;
Profile* profile = Profile::FromBrowserContext(
web_contents()->GetBrowserContext());
- TestFaviconHandler helper(page_url, profile,
- &delegate, FaviconHandler::TOUCH);
+ TestFaviconHandler helper(
+ page_url, profile, &driver, &delegate, FaviconHandler::TOUCH);
helper.FetchFavicon(page_url);
HistoryRequestHandler* history_handler = helper.history_handler();
@@ -881,10 +892,11 @@ TEST_F(FaviconHandlerTest, UpdateDuringDownloading) {
const GURL new_icon_url("http://www.google.com/new_favicon");
TestFaviconHandlerDelegate delegate;
+ TestFaviconDriver driver;
Profile* profile = Profile::FromBrowserContext(
web_contents()->GetBrowserContext());
- TestFaviconHandler helper(page_url, profile,
- &delegate, FaviconHandler::TOUCH);
+ TestFaviconHandler helper(
+ page_url, profile, &driver, &delegate, FaviconHandler::TOUCH);
helper.FetchFavicon(page_url);
HistoryRequestHandler* history_handler = helper.history_handler();
@@ -1025,8 +1037,9 @@ TEST_F(FaviconHandlerTest, MultipleFavicons) {
// 1) Test that if there are several single resolution favicons to choose from
// that the largest exact match is chosen.
TestFaviconHandlerDelegate delegate1;
- TestFaviconHandler handler1(kPageURL, profile,
- &delegate1, FaviconHandler::FAVICON);
+ TestFaviconDriver driver;
+ TestFaviconHandler handler1(
+ kPageURL, profile, &driver, &delegate1, FaviconHandler::FAVICON);
const int kSizes1[] = { 16, 24, 32, 48, 256 };
std::vector<FaviconURL> urls1(kSourceIconURLs,
kSourceIconURLs + arraysize(kSizes1));
@@ -1046,8 +1059,8 @@ TEST_F(FaviconHandlerTest, MultipleFavicons) {
// 2) Test that if there are several single resolution favicons to choose
// from, the exact match is preferred even if it results in upsampling.
TestFaviconHandlerDelegate delegate2;
- TestFaviconHandler handler2(kPageURL, profile,
- &delegate2, FaviconHandler::FAVICON);
+ TestFaviconHandler handler2(
+ kPageURL, profile, &driver, &delegate2, FaviconHandler::FAVICON);
const int kSizes2[] = { 16, 24, 48, 256 };
std::vector<FaviconURL> urls2(kSourceIconURLs,
kSourceIconURLs + arraysize(kSizes2));
@@ -1061,8 +1074,8 @@ TEST_F(FaviconHandlerTest, MultipleFavicons) {
// 3) Test that favicons which need to be upsampled a little or downsampled
// a little are preferred over huge favicons.
TestFaviconHandlerDelegate delegate3;
- TestFaviconHandler handler3(kPageURL, profile,
- &delegate3, FaviconHandler::FAVICON);
+ TestFaviconHandler handler3(
+ kPageURL, profile, &driver, &delegate3, FaviconHandler::FAVICON);
const int kSizes3[] = { 256, 48 };
std::vector<FaviconURL> urls3(kSourceIconURLs,
kSourceIconURLs + arraysize(kSizes3));
@@ -1074,8 +1087,8 @@ TEST_F(FaviconHandlerTest, MultipleFavicons) {
handler3.GetEntry()->GetFavicon().url);
TestFaviconHandlerDelegate delegate4;
- TestFaviconHandler handler4(kPageURL, profile,
- &delegate4, FaviconHandler::FAVICON);
+ TestFaviconHandler handler4(
+ kPageURL, profile, &driver, &delegate4, FaviconHandler::FAVICON);
const int kSizes4[] = { 17, 256 };
std::vector<FaviconURL> urls4(kSourceIconURLs,
kSourceIconURLs + arraysize(kSizes4));

Powered by Google App Engine
This is Rietveld 408576698