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

Side by Side Diff: chrome/browser/favicon/favicon_handler_unittest.cc

Issue 684983003: Add Observer in FaviconTabHelper (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 "chrome/browser/favicon/favicon_handler.h" 5 #include "chrome/browser/favicon/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.h" 8 #include "chrome/browser/favicon/chrome_favicon_client.h"
9 #include "chrome/browser/favicon/chrome_favicon_client_factory.h" 9 #include "chrome/browser/favicon/chrome_favicon_client_factory.h"
10 #include "chrome/browser/favicon/favicon_service.h" 10 #include "chrome/browser/favicon/favicon_service.h"
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 return -1; 220 return -1;
221 } 221 }
222 222
223 void NotifyFaviconUpdated(bool icon_url_changed) override { 223 void NotifyFaviconUpdated(bool icon_url_changed) override {
224 ADD_FAILURE() << "TestFaviconDriver::NotifyFaviconUpdated() " 224 ADD_FAILURE() << "TestFaviconDriver::NotifyFaviconUpdated() "
225 << "should never be called in tests."; 225 << "should never be called in tests.";
226 } 226 }
227 227
228 void SetActiveURL(GURL url) { url_ = url; } 228 void SetActiveURL(GURL url) { url_ = url; }
229 229
230 void OnFaviconAvailable(const gfx::Image& image) {
231 available_image_ = image;
232 }
233
234 const gfx::Image GetAvailableImage() {
235 return available_image_;
236 }
237
230 private: 238 private:
231 GURL favicon_url_; 239 GURL favicon_url_;
232 GURL url_; 240 GURL url_;
233 gfx::Image image_; 241 gfx::Image image_;
234 bool favicon_validity_; 242 bool favicon_validity_;
243 gfx::Image available_image_;
235 DISALLOW_COPY_AND_ASSIGN(TestFaviconDriver); 244 DISALLOW_COPY_AND_ASSIGN(TestFaviconDriver);
236 }; 245 };
237 246
238 // This class is used to catch the FaviconHandler's download and history 247 // This class is used to catch the FaviconHandler's download and history
239 // request, and also provide the methods to access the FaviconHandler 248 // request, and also provide the methods to access the FaviconHandler
240 // internals. 249 // internals.
241 class TestFaviconHandler : public FaviconHandler { 250 class TestFaviconHandler : public FaviconHandler {
242 public: 251 public:
243 static int GetMaximalIconSize(favicon_base::IconType icon_type) { 252 static int GetMaximalIconSize(favicon_base::IconType icon_type) {
244 return FaviconHandler::GetMaximalIconSize(icon_type); 253 return FaviconHandler::GetMaximalIconSize(icon_type);
(...skipping 1297 matching lines...) Expand 10 before | Expand all | Expand 10 after
1542 download_id = favicon_tab_helper->StartDownload(missing_icon_url, 0); 1551 download_id = favicon_tab_helper->StartDownload(missing_icon_url, 0);
1543 EXPECT_NE(0, download_id); 1552 EXPECT_NE(0, download_id);
1544 // Report download success with HTTP 200 status. 1553 // Report download success with HTTP 200 status.
1545 favicon_tab_helper->DidDownloadFavicon(download_id, 200, missing_icon_url, 1554 favicon_tab_helper->DidDownloadFavicon(download_id, 200, missing_icon_url,
1546 empty_icons, empty_icon_sizes); 1555 empty_icons, empty_icon_sizes);
1547 // Icon is not marked as UnableToDownload as HTTP status is not 404. 1556 // Icon is not marked as UnableToDownload as HTTP status is not 404.
1548 EXPECT_FALSE(favicon_service->WasUnableToDownloadFavicon(missing_icon_url)); 1557 EXPECT_FALSE(favicon_service->WasUnableToDownloadFavicon(missing_icon_url));
1549 } 1558 }
1550 1559
1551 } // namespace. 1560 } // namespace.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698