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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 virtual ~TestFaviconDownloader() {} |
55 | 55 |
56 virtual int DownloadImage(const GURL& url) OVERRIDE { | 56 virtual int DownloadImage(const GURL& url) override { |
57 return id_counter_++; | 57 return id_counter_++; |
58 } | 58 } |
59 | 59 |
60 virtual std::vector<content::FaviconURL> GetFaviconURLsFromWebContents() | 60 virtual std::vector<content::FaviconURL> GetFaviconURLsFromWebContents() |
61 OVERRIDE { | 61 override { |
62 return initial_favicon_urls_; | 62 return initial_favicon_urls_; |
63 } | 63 } |
64 | 64 |
65 size_t pending_requests() const { | 65 size_t pending_requests() const { |
66 return in_progress_requests_.size(); | 66 return in_progress_requests_.size(); |
67 } | 67 } |
68 | 68 |
69 void DownloadsComplete(bool success, | 69 void DownloadsComplete(bool success, |
70 const FaviconDownloader::FaviconMap& map) { | 70 const FaviconDownloader::FaviconMap& map) { |
71 favicon_map_ = map; | 71 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 | 181 // 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. | 182 // the URL was in both the web app info and the favicon urls. |
183 downloader.CompleteImageDownload(2, empty_favicon, std::vector<gfx::Size>()); | 183 downloader.CompleteImageDownload(2, empty_favicon, std::vector<gfx::Size>()); |
184 EXPECT_EQ(0u, downloader.pending_requests()); | 184 EXPECT_EQ(0u, downloader.pending_requests()); |
185 | 185 |
186 EXPECT_EQ(3u, downloader.favicon_map().size()); | 186 EXPECT_EQ(3u, downloader.favicon_map().size()); |
187 EXPECT_EQ(0u, downloader.favicon_map()[empty_favicon].size()); | 187 EXPECT_EQ(0u, downloader.favicon_map()[empty_favicon].size()); |
188 EXPECT_EQ(1u, downloader.favicon_map()[favicon_url_1].size()); | 188 EXPECT_EQ(1u, downloader.favicon_map()[favicon_url_1].size()); |
189 EXPECT_EQ(2u, downloader.favicon_map()[favicon_url_2].size()); | 189 EXPECT_EQ(2u, downloader.favicon_map()[favicon_url_2].size()); |
190 } | 190 } |
OLD | NEW |