| OLD | NEW |
| 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 "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "chrome/browser/favicon/chrome_favicon_client_factory.h" | 8 #include "chrome/browser/favicon/chrome_favicon_client_factory.h" |
| 9 #include "chrome/browser/favicon/favicon_service_factory.h" | 9 #include "chrome/browser/favicon/favicon_service_factory.h" |
| 10 #include "chrome/browser/favicon/favicon_tab_helper.h" | 10 #include "chrome/browser/favicon/favicon_tab_helper.h" |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 class TestFaviconDriver : public favicon::FaviconDriver { | 176 class TestFaviconDriver : public favicon::FaviconDriver { |
| 177 public: | 177 public: |
| 178 TestFaviconDriver() | 178 TestFaviconDriver() |
| 179 : favicon_validity_(false), | 179 : favicon_validity_(false), |
| 180 num_active_favicon_(0), | 180 num_active_favicon_(0), |
| 181 num_favicon_available_(0), | 181 num_favicon_available_(0), |
| 182 update_active_favicon_(false) {} | 182 update_active_favicon_(false) {} |
| 183 | 183 |
| 184 ~TestFaviconDriver() override {} | 184 ~TestFaviconDriver() override {} |
| 185 | 185 |
| 186 // favicon::FaviconDriver implementation. |
| 187 void FetchFavicon(const GURL& url) override { |
| 188 ADD_FAILURE() << "TestFaviconDriver::FetchFavicon() " |
| 189 << "should never be called in tests."; |
| 190 } |
| 191 |
| 192 void SaveFavicon() override { |
| 193 ADD_FAILURE() << "TestFaviconDriver::SaveFavicon() " |
| 194 << "should never be called in tests."; |
| 195 } |
| 196 |
| 197 gfx::Image GetFavicon() const override { |
| 198 ADD_FAILURE() << "TestFaviconDriver::GetFavicon() " |
| 199 << "should never be called in tests."; |
| 200 return gfx::Image(); |
| 201 } |
| 202 |
| 203 bool FaviconIsValid() const override { |
| 204 ADD_FAILURE() << "TestFaviconDriver::FaviconIsValid() " |
| 205 << "should never be called in tests."; |
| 206 return false; |
| 207 } |
| 208 |
| 209 bool HasPendingTasksForTest() override { |
| 210 ADD_FAILURE() << "TestFaviconDriver::HasPendingTasksForTest() " |
| 211 << "should never be called in tests."; |
| 212 return false; |
| 213 } |
| 214 |
| 186 int StartDownload(const GURL& url, int max_bitmap_size) override { | 215 int StartDownload(const GURL& url, int max_bitmap_size) override { |
| 187 ADD_FAILURE() << "TestFaviconDriver::StartDownload() " | 216 ADD_FAILURE() << "TestFaviconDriver::StartDownload() " |
| 188 << "should never be called in tests."; | 217 << "should never be called in tests."; |
| 189 return -1; | 218 return -1; |
| 190 } | 219 } |
| 191 | 220 |
| 192 bool IsOffTheRecord() override { return false; } | 221 bool IsOffTheRecord() override { return false; } |
| 193 | 222 |
| 194 bool IsBookmarked(const GURL& url) override { return false; } | 223 bool IsBookmarked(const GURL& url) override { return false; } |
| 195 | 224 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 224 update_active_favicon_ = update_active_favicon; | 253 update_active_favicon_ = update_active_favicon; |
| 225 if (!update_active_favicon) | 254 if (!update_active_favicon) |
| 226 return; | 255 return; |
| 227 | 256 |
| 228 ++num_active_favicon_; | 257 ++num_active_favicon_; |
| 229 SetActiveFaviconURL(icon_url); | 258 SetActiveFaviconURL(icon_url); |
| 230 SetActiveFaviconValidity(true); | 259 SetActiveFaviconValidity(true); |
| 231 SetActiveFaviconImage(image); | 260 SetActiveFaviconImage(image); |
| 232 } | 261 } |
| 233 | 262 |
| 234 void NotifyFaviconUpdated(bool icon_url_changed) override {} | |
| 235 | |
| 236 size_t num_active_favicon() const { return num_active_favicon_; } | 263 size_t num_active_favicon() const { return num_active_favicon_; } |
| 237 size_t num_favicon_available() const { return num_favicon_available_; } | 264 size_t num_favicon_available() const { return num_favicon_available_; } |
| 238 void ResetNumActiveFavicon() { num_active_favicon_ = 0; } | 265 void ResetNumActiveFavicon() { num_active_favicon_ = 0; } |
| 239 void ResetNumFaviconAvailable() { num_favicon_available_ = 0; } | 266 void ResetNumFaviconAvailable() { num_favicon_available_ = 0; } |
| 240 | 267 |
| 241 void SetActiveURL(GURL url) { url_ = url; } | 268 void SetActiveURL(GURL url) { url_ = url; } |
| 242 | 269 |
| 243 const gfx::Image available_favicon() { return available_image_; } | 270 const gfx::Image available_favicon() { return available_image_; } |
| 244 | 271 |
| 245 const GURL available_icon_url() { return available_icon_url_; } | 272 const GURL available_icon_url() { return available_icon_url_; } |
| (...skipping 1391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1637 EXPECT_EQ(new_favicon_url, driver1.available_icon_url()); | 1664 EXPECT_EQ(new_favicon_url, driver1.available_icon_url()); |
| 1638 EXPECT_FALSE(driver1.update_active_favicon()); | 1665 EXPECT_FALSE(driver1.update_active_favicon()); |
| 1639 EXPECT_EQ(3u, driver1.num_favicon_available()); | 1666 EXPECT_EQ(3u, driver1.num_favicon_available()); |
| 1640 } | 1667 } |
| 1641 | 1668 |
| 1642 INSTANTIATE_TEST_CASE_P(FaviconHandlerTestActiveFaviconValidityTrueOrFalse, | 1669 INSTANTIATE_TEST_CASE_P(FaviconHandlerTestActiveFaviconValidityTrueOrFalse, |
| 1643 FaviconHandlerActiveFaviconValidityParamTest, | 1670 FaviconHandlerActiveFaviconValidityParamTest, |
| 1644 ::testing::Bool()); | 1671 ::testing::Bool()); |
| 1645 | 1672 |
| 1646 } // namespace. | 1673 } // namespace. |
| OLD | NEW |