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

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

Issue 12212048: Linux/ChromeOS Chromium style checker cleanup, chrome/browser edition. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 7 years, 10 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 | Annotate | Revision Log
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 "base/memory/scoped_ptr.h" 5 #include "base/memory/scoped_ptr.h"
6 #include "chrome/browser/favicon/favicon_handler.h" 6 #include "chrome/browser/favicon/favicon_handler.h"
7 #include "chrome/browser/profiles/profile.h" 7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 8 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
9 #include "content/public/browser/favicon_status.h" 9 #include "content/public/browser/favicon_status.h"
10 #include "content/public/browser/invalidate_type.h" 10 #include "content/public/browser/invalidate_type.h"
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 // the various delegate methods. Most of these methods are actually never 164 // the various delegate methods. Most of these methods are actually never
165 // called. 165 // called.
166 // TODO(rohitrao): Refactor the tests to override these delegate methods instead 166 // TODO(rohitrao): Refactor the tests to override these delegate methods instead
167 // of subclassing. 167 // of subclassing.
168 class TestFaviconHandlerDelegate : public FaviconHandlerDelegate { 168 class TestFaviconHandlerDelegate : public FaviconHandlerDelegate {
169 public: 169 public:
170 explicit TestFaviconHandlerDelegate(WebContents* web_contents) 170 explicit TestFaviconHandlerDelegate(WebContents* web_contents)
171 : web_contents_(web_contents) { 171 : web_contents_(web_contents) {
172 } 172 }
173 173
174 virtual NavigationEntry* GetActiveEntry() { 174 virtual NavigationEntry* GetActiveEntry() OVERRIDE {
175 ADD_FAILURE() << "TestFaviconHandlerDelegate::GetActiveEntry() " 175 ADD_FAILURE() << "TestFaviconHandlerDelegate::GetActiveEntry() "
176 << "should never be called in tests."; 176 << "should never be called in tests.";
177 return NULL; 177 return NULL;
178 } 178 }
179 179
180 virtual int StartDownload(const GURL& url, int image_size) { 180 virtual int StartDownload(const GURL& url, int image_size) OVERRIDE {
181 ADD_FAILURE() << "TestFaviconHandlerDelegate::StartDownload() " 181 ADD_FAILURE() << "TestFaviconHandlerDelegate::StartDownload() "
182 << "should never be called in tests."; 182 << "should never be called in tests.";
183 return -1; 183 return -1;
184 } 184 }
185 185
186 virtual void NotifyFaviconUpdated() { 186 virtual void NotifyFaviconUpdated() OVERRIDE {
187 web_contents_->NotifyNavigationStateChanged(content::INVALIDATE_TYPE_TAB); 187 web_contents_->NotifyNavigationStateChanged(content::INVALIDATE_TYPE_TAB);
188 } 188 }
189 189
190 private: 190 private:
191 WebContents* web_contents_; // weak 191 WebContents* web_contents_; // weak
192 }; 192 };
193 193
194 // This class is used to catch the FaviconHandler's download and history 194 // This class is used to catch the FaviconHandler's download and history
195 // request, and also provide the methods to access the FaviconHandler 195 // request, and also provide the methods to access the FaviconHandler
196 // internals. 196 // internals.
(...skipping 19 matching lines...) Expand all
216 216
217 // This method will take the ownership of the given handler. 217 // This method will take the ownership of the given handler.
218 void set_history_handler(HistoryRequestHandler* handler) { 218 void set_history_handler(HistoryRequestHandler* handler) {
219 history_handler_.reset(handler); 219 history_handler_.reset(handler);
220 } 220 }
221 221
222 DownloadHandler* download_handler() { 222 DownloadHandler* download_handler() {
223 return download_handler_.get(); 223 return download_handler_.get();
224 } 224 }
225 225
226 virtual NavigationEntry* GetEntry() { 226 virtual NavigationEntry* GetEntry() OVERRIDE {
227 return entry_.get(); 227 return entry_.get();
228 } 228 }
229 229
230 const std::deque<FaviconURL>& urls() { 230 const std::deque<FaviconURL>& urls() {
231 return image_urls_; 231 return image_urls_;
232 } 232 }
233 233
234 void FetchFavicon(const GURL& url) { 234 void FetchFavicon(const GURL& url) {
235 FaviconHandler::FetchFavicon(url); 235 FaviconHandler::FetchFavicon(url);
236 } 236 }
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 947
948 // Verify correct icon size chosen. 948 // Verify correct icon size chosen.
949 EXPECT_EQ(icon_url_preferred1, handler.GetEntry()->GetFavicon().url); 949 EXPECT_EQ(icon_url_preferred1, handler.GetEntry()->GetFavicon().url);
950 EXPECT_TRUE(handler.GetEntry()->GetFavicon().valid); 950 EXPECT_TRUE(handler.GetEntry()->GetFavicon().valid);
951 EXPECT_FALSE(handler.GetEntry()->GetFavicon().image.IsEmpty()); 951 EXPECT_FALSE(handler.GetEntry()->GetFavicon().image.IsEmpty());
952 EXPECT_EQ(gfx::kFaviconSize, 952 EXPECT_EQ(gfx::kFaviconSize,
953 handler.GetEntry()->GetFavicon().image.ToSkBitmap()->width()); 953 handler.GetEntry()->GetFavicon().image.ToSkBitmap()->width());
954 } 954 }
955 955
956 } // namespace. 956 } // namespace.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698