| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/extensions/favicon_downloader.h" | 5 #include "chrome/browser/extensions/favicon_downloader.h" |
| 6 | 6 |
| 7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.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/common/favicon_url.h" | 9 #include "content/public/common/favicon_url.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 public: | 44 public: |
| 45 TestFaviconDownloader(content::WebContents* web_contents, | 45 TestFaviconDownloader(content::WebContents* web_contents, |
| 46 std::vector<GURL> extra_favicon_urls) | 46 std::vector<GURL> extra_favicon_urls) |
| 47 : FaviconDownloader( | 47 : FaviconDownloader( |
| 48 web_contents, | 48 web_contents, |
| 49 extra_favicon_urls, | 49 extra_favicon_urls, |
| 50 base::Bind(&TestFaviconDownloader::DownloadsComplete, | 50 base::Bind(&TestFaviconDownloader::DownloadsComplete, |
| 51 base::Unretained(this))), | 51 base::Unretained(this))), |
| 52 id_counter_(0) { | 52 id_counter_(0) { |
| 53 } | 53 } |
| 54 virtual ~TestFaviconDownloader() {} | 54 ~TestFaviconDownloader() override {} |
| 55 | 55 |
| 56 virtual int DownloadImage(const GURL& url) override { | 56 int DownloadImage(const GURL& url) override { return id_counter_++; } |
| 57 return id_counter_++; | |
| 58 } | |
| 59 | 57 |
| 60 virtual std::vector<content::FaviconURL> GetFaviconURLsFromWebContents() | 58 std::vector<content::FaviconURL> GetFaviconURLsFromWebContents() override { |
| 61 override { | |
| 62 return initial_favicon_urls_; | 59 return initial_favicon_urls_; |
| 63 } | 60 } |
| 64 | 61 |
| 65 size_t pending_requests() const { | 62 size_t pending_requests() const { |
| 66 return in_progress_requests_.size(); | 63 return in_progress_requests_.size(); |
| 67 } | 64 } |
| 68 | 65 |
| 69 void DownloadsComplete(bool success, | 66 void DownloadsComplete(bool success, |
| 70 const FaviconDownloader::FaviconMap& map) { | 67 const FaviconDownloader::FaviconMap& map) { |
| 71 favicon_map_ = map; | 68 favicon_map_ = map; |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 // Only 1 download should have been initiated for |empty_favicon| even though | 178 // Only 1 download should have been initiated for |empty_favicon| even though |
| 182 // the URL was in both the web app info and the favicon urls. | 179 // the URL was in both the web app info and the favicon urls. |
| 183 downloader.CompleteImageDownload(2, empty_favicon, std::vector<gfx::Size>()); | 180 downloader.CompleteImageDownload(2, empty_favicon, std::vector<gfx::Size>()); |
| 184 EXPECT_EQ(0u, downloader.pending_requests()); | 181 EXPECT_EQ(0u, downloader.pending_requests()); |
| 185 | 182 |
| 186 EXPECT_EQ(3u, downloader.favicon_map().size()); | 183 EXPECT_EQ(3u, downloader.favicon_map().size()); |
| 187 EXPECT_EQ(0u, downloader.favicon_map()[empty_favicon].size()); | 184 EXPECT_EQ(0u, downloader.favicon_map()[empty_favicon].size()); |
| 188 EXPECT_EQ(1u, downloader.favicon_map()[favicon_url_1].size()); | 185 EXPECT_EQ(1u, downloader.favicon_map()[favicon_url_1].size()); |
| 189 EXPECT_EQ(2u, downloader.favicon_map()[favicon_url_2].size()); | 186 EXPECT_EQ(2u, downloader.favicon_map()[favicon_url_2].size()); |
| 190 } | 187 } |
| OLD | NEW |