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

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

Issue 11746010: Cleanup history favicon code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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
« no previous file with comments | « chrome/browser/favicon/favicon_handler.cc ('k') | chrome/browser/favicon/favicon_service.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 scoped_ptr<DownloadHandler> download_handler_; 307 scoped_ptr<DownloadHandler> download_handler_;
308 scoped_ptr<HistoryRequestHandler> history_handler_; 308 scoped_ptr<HistoryRequestHandler> history_handler_;
309 309
310 DISALLOW_COPY_AND_ASSIGN(TestFaviconHandler); 310 DISALLOW_COPY_AND_ASSIGN(TestFaviconHandler);
311 }; 311 };
312 312
313 namespace { 313 namespace {
314 314
315 void HistoryRequestHandler::InvokeCallback() { 315 void HistoryRequestHandler::InvokeCallback() {
316 if (!callback_.is_null()) { 316 if (!callback_.is_null()) {
317 history::IconURLSizesMap icon_url_sizes; 317 callback_.Run(history_results_);
318 // Build IconURLSizesMap such that the requirement that all the icon URLs
319 // in |history_results_| be present in |icon_url_sizes| holds.
320 // Add the pixel size for each of |history_results_| to |icon_url_sizes|
321 // as empty favicon sizes has a special meaning.
322 for (size_t i = 0; i < history_results_.size(); ++i) {
323 const history::FaviconBitmapResult& bitmap_result = history_results_[i];
324 const GURL& icon_url = bitmap_result.icon_url;
325 icon_url_sizes[icon_url].push_back(bitmap_result.pixel_size);
326 }
327
328 callback_.Run(history_results_, icon_url_sizes);
329 } 318 }
330 } 319 }
331 320
332 void DownloadHandler::InvokeCallback() { 321 void DownloadHandler::InvokeCallback() {
333 SkBitmap bitmap; 322 SkBitmap bitmap;
334 const int kRequestedSize = gfx::kFaviconSize; 323 const int kRequestedSize = gfx::kFaviconSize;
335 int downloaded_size = (download_->image_size > 0) ? 324 int downloaded_size = (download_->image_size > 0) ?
336 download_->image_size : gfx::kFaviconSize; 325 download_->image_size : gfx::kFaviconSize;
337 FillDataToBitmap(downloaded_size, downloaded_size, &bitmap); 326 FillDataToBitmap(downloaded_size, downloaded_size, &bitmap);
338 std::vector<SkBitmap> bitmaps; 327 std::vector<SkBitmap> bitmaps;
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
958 947
959 // Verify correct icon size chosen. 948 // Verify correct icon size chosen.
960 EXPECT_EQ(icon_url_preferred1, handler.GetEntry()->GetFavicon().url); 949 EXPECT_EQ(icon_url_preferred1, handler.GetEntry()->GetFavicon().url);
961 EXPECT_TRUE(handler.GetEntry()->GetFavicon().valid); 950 EXPECT_TRUE(handler.GetEntry()->GetFavicon().valid);
962 EXPECT_FALSE(handler.GetEntry()->GetFavicon().image.IsEmpty()); 951 EXPECT_FALSE(handler.GetEntry()->GetFavicon().image.IsEmpty());
963 EXPECT_EQ(gfx::kFaviconSize, 952 EXPECT_EQ(gfx::kFaviconSize,
964 handler.GetEntry()->GetFavicon().image.ToSkBitmap()->width()); 953 handler.GetEntry()->GetFavicon().image.ToSkBitmap()->width());
965 } 954 }
966 955
967 } // namespace. 956 } // namespace.
OLDNEW
« no previous file with comments | « chrome/browser/favicon/favicon_handler.cc ('k') | chrome/browser/favicon/favicon_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698