summaryrefslogtreecommitdiffstats
path: root/chrome/browser/favicon/favicon_handler_unittest.cc
diff options
context:
space:
mode:
authorsdefresne <sdefresne@chromium.org>2015-03-30 10:17:11 -0700
committerCommit bot <commit-bot@chromium.org>2015-03-30 17:18:00 +0000
commit494aec68691f10626b226892396d442503dd9af7 (patch)
tree3cf53649ec6e4c708d419928ca798b5bc6641dee /chrome/browser/favicon/favicon_handler_unittest.cc
parent24c5e71f6cc5f1033485d83bd7d767c45071cf16 (diff)
downloadchromium_src-494aec68691f10626b226892396d442503dd9af7.zip
chromium_src-494aec68691f10626b226892396d442503dd9af7.tar.gz
chromium_src-494aec68691f10626b226892396d442503dd9af7.tar.bz2
Move //components/favicon code into the favicon namespace
Move all classes defined in //components/favicon into the favicon namespace and update all client code forward-declaration and usage. Rename FaviconTabHelperObserver to FaviconDriverObserver as FaviconDriver is the name of the base interface (and iOS wants to use that observer but will not be able to use FaviconTabHelper). BUG=359513 Review URL: https://codereview.chromium.org/1028503004 Cr-Commit-Position: refs/heads/master@{#322799}
Diffstat (limited to 'chrome/browser/favicon/favicon_handler_unittest.cc')
-rw-r--r--chrome/browser/favicon/favicon_handler_unittest.cc100
1 files changed, 53 insertions, 47 deletions
diff --git a/chrome/browser/favicon/favicon_handler_unittest.cc b/chrome/browser/favicon/favicon_handler_unittest.cc
index 4e4dd4c..be9db08 100644
--- a/chrome/browser/favicon/favicon_handler_unittest.cc
+++ b/chrome/browser/favicon/favicon_handler_unittest.cc
@@ -174,12 +174,12 @@ class HistoryRequestHandler {
} // namespace
-class TestFaviconClient : public FaviconClient {
+class TestFaviconClient : public favicon::FaviconClient {
public:
~TestFaviconClient() override {}
private:
- // FaviconClient implementation.
+ // favicon::FaviconClient implementation.
bool IsBookmarked(const GURL& url) override { return false; }
bool IsNativeApplicationURL(const GURL& url) override { return false; }
base::CancelableTaskTracker::TaskId GetFaviconForNativeApplicationURL(
@@ -191,7 +191,7 @@ class TestFaviconClient : public FaviconClient {
}
};
-class TestFaviconDriver : public FaviconDriver {
+class TestFaviconDriver : public favicon::FaviconDriver {
public:
TestFaviconDriver()
: favicon_validity_(false),
@@ -275,18 +275,22 @@ class TestFaviconDriver : public FaviconDriver {
// This class is used to catch the FaviconHandler's download and history
// request, and also provide the methods to access the FaviconHandler
// internals.
-class TestFaviconHandler : public FaviconHandler {
+class TestFaviconHandler : public favicon::FaviconHandler {
public:
static int GetMaximalIconSize(favicon_base::IconType icon_type) {
return FaviconHandler::GetMaximalIconSize(icon_type);
}
TestFaviconHandler(const GURL& page_url,
- FaviconClient* client,
+ favicon::FaviconClient* client,
TestFaviconDriver* driver,
Type type,
bool download_largest_icon)
- : FaviconHandler(nullptr, client, driver, type, download_largest_icon),
+ : favicon::FaviconHandler(nullptr,
+ client,
+ driver,
+ type,
+ download_largest_icon),
download_id_(0) {
driver->SetActiveURL(page_url);
download_handler_.reset(new DownloadHandler(this));
@@ -313,7 +317,7 @@ class TestFaviconHandler : public FaviconHandler {
}
FaviconURL* current_candidate() {
- return FaviconHandler::current_candidate();
+ return favicon::FaviconHandler::current_candidate();
}
const FaviconCandidate& best_favicon_candidate() {
@@ -472,7 +476,7 @@ class FaviconHandlerTest : public ChromeRenderViewHostTestHarness {
void SetUp() override {
// The score computed by SelectFaviconFrames() is dependent on the supported
// scale factors of the platform. It is used for determining the goodness of
- // a downloaded bitmap in FaviconHandler::OnDidDownloadFavicon().
+ // a downloaded bitmap in favicon::FaviconHandler::OnDidDownloadFavicon().
// Force the values of the scale factors so that the tests produce the same
// results on all platforms.
std::vector<ui::ScaleFactor> scale_factors;
@@ -503,8 +507,8 @@ TEST_F(FaviconHandlerTest, GetFaviconFromHistory) {
TestFaviconDriver driver;
TestFaviconClient client;
- TestFaviconHandler helper(
- page_url, &client, &driver, FaviconHandler::FAVICON, false);
+ TestFaviconHandler helper(page_url, &client, &driver,
+ favicon::FaviconHandler::FAVICON, false);
helper.FetchFavicon(page_url);
HistoryRequestHandler* history_handler = helper.history_handler();
@@ -544,8 +548,8 @@ TEST_F(FaviconHandlerTest, DownloadFavicon) {
TestFaviconDriver driver;
TestFaviconClient client;
- TestFaviconHandler helper(
- page_url, &client, &driver, FaviconHandler::FAVICON, false);
+ TestFaviconHandler helper(page_url, &client, &driver,
+ favicon::FaviconHandler::FAVICON, false);
helper.FetchFavicon(page_url);
HistoryRequestHandler* history_handler = helper.history_handler();
@@ -613,8 +617,8 @@ TEST_F(FaviconHandlerTest, UpdateAndDownloadFavicon) {
TestFaviconDriver driver;
TestFaviconClient client;
- TestFaviconHandler helper(
- page_url, &client, &driver, FaviconHandler::FAVICON, false);
+ TestFaviconHandler helper(page_url, &client, &driver,
+ favicon::FaviconHandler::FAVICON, false);
helper.FetchFavicon(page_url);
HistoryRequestHandler* history_handler = helper.history_handler();
@@ -694,8 +698,8 @@ TEST_F(FaviconHandlerTest, FaviconInHistoryInvalid) {
TestFaviconDriver driver;
TestFaviconClient client;
- TestFaviconHandler helper(
- page_url, &client, &driver, FaviconHandler::FAVICON, false);
+ TestFaviconHandler helper(page_url, &client, &driver,
+ favicon::FaviconHandler::FAVICON, false);
helper.FetchFavicon(page_url);
HistoryRequestHandler* history_handler = helper.history_handler();
@@ -766,8 +770,8 @@ TEST_F(FaviconHandlerTest, UpdateFavicon) {
TestFaviconDriver driver;
TestFaviconClient client;
- TestFaviconHandler helper(
- page_url, &client, &driver, FaviconHandler::FAVICON, false);
+ TestFaviconHandler helper(page_url, &client, &driver,
+ favicon::FaviconHandler::FAVICON, false);
helper.FetchFavicon(page_url);
HistoryRequestHandler* history_handler = helper.history_handler();
@@ -828,8 +832,8 @@ TEST_F(FaviconHandlerTest, Download2ndFaviconURLCandidate) {
TestFaviconDriver driver;
TestFaviconClient client;
- TestFaviconHandler helper(
- page_url, &client, &driver, FaviconHandler::TOUCH, false);
+ TestFaviconHandler helper(page_url, &client, &driver,
+ favicon::FaviconHandler::TOUCH, false);
helper.FetchFavicon(page_url);
HistoryRequestHandler* history_handler = helper.history_handler();
@@ -943,8 +947,8 @@ TEST_F(FaviconHandlerTest, UpdateDuringDownloading) {
TestFaviconDriver driver;
TestFaviconClient client;
- TestFaviconHandler helper(
- page_url, &client, &driver, FaviconHandler::TOUCH, false);
+ TestFaviconHandler helper(page_url, &client, &driver,
+ favicon::FaviconHandler::TOUCH, false);
helper.FetchFavicon(page_url);
HistoryRequestHandler* history_handler = helper.history_handler();
@@ -1086,8 +1090,8 @@ TEST_F(FaviconHandlerTest, MultipleFavicons) {
// that the largest exact match is chosen.
TestFaviconDriver driver1;
TestFaviconClient client;
- TestFaviconHandler handler1(
- kPageURL, &client, &driver1, FaviconHandler::FAVICON, false);
+ TestFaviconHandler handler1(kPageURL, &client, &driver1,
+ favicon::FaviconHandler::FAVICON, false);
const int kSizes1[] = { 16, 24, 32, 48, 256 };
std::vector<FaviconURL> urls1(kSourceIconURLs,
@@ -1108,8 +1112,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.
TestFaviconDriver driver2;
- TestFaviconHandler handler2(
- kPageURL, &client, &driver2, FaviconHandler::FAVICON, false);
+ TestFaviconHandler handler2(kPageURL, &client, &driver2,
+ favicon::FaviconHandler::FAVICON, false);
const int kSizes2[] = { 16, 24, 48, 256 };
std::vector<FaviconURL> urls2(kSourceIconURLs,
@@ -1125,8 +1129,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.
TestFaviconDriver driver3;
- TestFaviconHandler handler3(
- kPageURL, &client, &driver3, FaviconHandler::FAVICON, false);
+ TestFaviconHandler handler3(kPageURL, &client, &driver3,
+ favicon::FaviconHandler::FAVICON, false);
const int kSizes3[] = { 256, 48 };
std::vector<FaviconURL> urls3(kSourceIconURLs,
@@ -1140,8 +1144,8 @@ TEST_F(FaviconHandlerTest, MultipleFavicons) {
driver3.GetActiveFaviconURL());
TestFaviconDriver driver4;
- TestFaviconHandler handler4(
- kPageURL, &client, &driver4, FaviconHandler::FAVICON, false);
+ TestFaviconHandler handler4(kPageURL, &client, &driver4,
+ favicon::FaviconHandler::FAVICON, false);
const int kSizes4[] = { 17, 256 };
std::vector<FaviconURL> urls4(kSourceIconURLs,
@@ -1184,8 +1188,8 @@ TEST_F(FaviconHandlerTest, TestSortFavicon) {
TestFaviconClient client;
TestFaviconDriver driver1;
- TestFaviconHandler handler1(
- kPageURL, &client, &driver1, FaviconHandler::FAVICON, true);
+ TestFaviconHandler handler1(kPageURL, &client, &driver1,
+ favicon::FaviconHandler::FAVICON, true);
std::vector<FaviconURL> urls1(kSourceIconURLs,
kSourceIconURLs + arraysize(kSourceIconURLs));
UpdateFaviconURL(&driver1, &handler1, kPageURL, urls1);
@@ -1248,8 +1252,8 @@ TEST_F(FaviconHandlerTest, TestDownloadLargestFavicon) {
TestFaviconClient client;
TestFaviconDriver driver1;
- TestFaviconHandler handler1(
- kPageURL, &client, &driver1, FaviconHandler::FAVICON, true);
+ TestFaviconHandler handler1(kPageURL, &client, &driver1,
+ favicon::FaviconHandler::FAVICON, true);
std::vector<FaviconURL> urls1(kSourceIconURLs,
kSourceIconURLs + arraysize(kSourceIconURLs));
UpdateFaviconURL(&driver1, &handler1, kPageURL, urls1);
@@ -1314,8 +1318,8 @@ TEST_F(FaviconHandlerTest, TestSelectLargestFavicon) {
TestFaviconClient client;
TestFaviconDriver driver1;
- TestFaviconHandler handler1(
- kPageURL, &client, &driver1, FaviconHandler::FAVICON, true);
+ TestFaviconHandler handler1(kPageURL, &client, &driver1,
+ favicon::FaviconHandler::FAVICON, true);
std::vector<FaviconURL> urls1(kSourceIconURLs,
kSourceIconURLs + arraysize(kSourceIconURLs));
UpdateFaviconURL(&driver1, &handler1, kPageURL, urls1);
@@ -1382,8 +1386,8 @@ TEST_F(FaviconHandlerTest, TestFaviconWasScaledAfterDownload) {
TestFaviconClient client;
TestFaviconDriver driver1;
- TestFaviconHandler handler1(
- kPageURL, &client, &driver1, FaviconHandler::FAVICON, true);
+ TestFaviconHandler handler1(kPageURL, &client, &driver1,
+ favicon::FaviconHandler::FAVICON, true);
std::vector<FaviconURL> urls1(kSourceIconURLs,
kSourceIconURLs + arraysize(kSourceIconURLs));
UpdateFaviconURL(&driver1, &handler1, kPageURL, urls1);
@@ -1444,8 +1448,8 @@ TEST_F(FaviconHandlerTest, TestKeepDownloadedLargestFavicon) {
TestFaviconClient client;
TestFaviconDriver driver1;
- TestFaviconHandler handler1(
- kPageURL, &client, &driver1, FaviconHandler::FAVICON, true);
+ TestFaviconHandler handler1(kPageURL, &client, &driver1,
+ favicon::FaviconHandler::FAVICON, true);
std::vector<FaviconURL> urls1(kSourceIconURLs,
kSourceIconURLs + arraysize(kSourceIconURLs));
UpdateFaviconURL(&driver1, &handler1, kPageURL, urls1);
@@ -1495,9 +1499,10 @@ TEST_F(FaviconHandlerTest, TestKeepDownloadedLargestFavicon) {
static KeyedService* BuildFaviconService(content::BrowserContext* context) {
Profile* profile = Profile::FromBrowserContext(context);
- return new FaviconService(ChromeFaviconClientFactory::GetForProfile(profile),
- HistoryServiceFactory::GetForProfile(
- profile, ServiceAccessType::EXPLICIT_ACCESS));
+ return new favicon::FaviconService(
+ ChromeFaviconClientFactory::GetForProfile(profile),
+ HistoryServiceFactory::GetForProfile(profile,
+ ServiceAccessType::EXPLICIT_ACCESS));
}
static KeyedService* BuildHistoryService(content::BrowserContext* context) {
@@ -1519,8 +1524,9 @@ TEST_F(FaviconHandlerTest, UnableToDownloadFavicon) {
HistoryServiceFactory::GetInstance()->SetTestingFactory(
profile, BuildHistoryService);
- FaviconService* favicon_service = FaviconServiceFactory::GetForProfile(
- profile, ServiceAccessType::IMPLICIT_ACCESS);
+ favicon::FaviconService* favicon_service =
+ FaviconServiceFactory::GetForProfile(profile,
+ ServiceAccessType::IMPLICIT_ACCESS);
FaviconTabHelper::CreateForWebContents(web_contents());
FaviconTabHelper* favicon_tab_helper =
@@ -1608,8 +1614,8 @@ TEST_P(FaviconHandlerActiveFaviconValidityParamTest,
FaviconURL(new_favicon_url, favicon_base::FAVICON, one_icon)};
TestFaviconClient client;
TestFaviconDriver driver1;
- TestFaviconHandler handler1(
- page_url, &client, &driver1, FaviconHandler::FAVICON, true);
+ TestFaviconHandler handler1(page_url, &client, &driver1,
+ favicon::FaviconHandler::FAVICON, true);
std::vector<FaviconURL> urls1(source_icon_urls,
source_icon_urls + arraysize(source_icon_urls));
UpdateFaviconURL(&driver1, &handler1, page_url, urls1);