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

Side by Side Diff: chrome/browser/extensions/favicon_downloader_unittest.cc

Issue 2918903002: Move IconURLs method from WebFrame to WebLocalFrame (Closed)
Patch Set: s/kFavIcon/kFavicon/g (as suggested in CR feedback from pkotwicz@). Created 3 years, 6 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
OLDNEW
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 FaviconDownloader::FaviconMap favicon_map_; 96 FaviconDownloader::FaviconMap favicon_map_;
97 int id_counter_; 97 int id_counter_;
98 DISALLOW_COPY_AND_ASSIGN(TestFaviconDownloader); 98 DISALLOW_COPY_AND_ASSIGN(TestFaviconDownloader);
99 }; 99 };
100 100
101 TEST_F(FaviconDownloaderTest, SimpleDownload) { 101 TEST_F(FaviconDownloaderTest, SimpleDownload) {
102 const GURL favicon_url("http://www.google.com/favicon.ico"); 102 const GURL favicon_url("http://www.google.com/favicon.ico");
103 TestFaviconDownloader downloader(web_contents(), std::vector<GURL>()); 103 TestFaviconDownloader downloader(web_contents(), std::vector<GURL>());
104 104
105 std::vector<content::FaviconURL> favicon_urls; 105 std::vector<content::FaviconURL> favicon_urls;
106 favicon_urls.push_back(content::FaviconURL( 106 favicon_urls.push_back(
107 favicon_url, content::FaviconURL::FAVICON, std::vector<gfx::Size>())); 107 content::FaviconURL(favicon_url, content::FaviconURL::IconType::kFavicon,
108 std::vector<gfx::Size>()));
108 downloader.set_initial_favicon_urls(favicon_urls); 109 downloader.set_initial_favicon_urls(favicon_urls);
109 EXPECT_EQ(0u, downloader.pending_requests()); 110 EXPECT_EQ(0u, downloader.pending_requests());
110 111
111 downloader.Start(); 112 downloader.Start();
112 EXPECT_EQ(1u, downloader.pending_requests()); 113 EXPECT_EQ(1u, downloader.pending_requests());
113 114
114 std::vector<gfx::Size> sizes(1, gfx::Size(32, 32)); 115 std::vector<gfx::Size> sizes(1, gfx::Size(32, 32));
115 downloader.CompleteImageDownload(0, favicon_urls[0].icon_url, sizes); 116 downloader.CompleteImageDownload(0, favicon_urls[0].icon_url, sizes);
116 EXPECT_EQ(0u, downloader.pending_requests()); 117 EXPECT_EQ(0u, downloader.pending_requests());
117 118
118 EXPECT_EQ(1u, downloader.favicon_map().size()); 119 EXPECT_EQ(1u, downloader.favicon_map().size());
119 EXPECT_EQ(1u, downloader.favicon_map()[favicon_url].size()); 120 EXPECT_EQ(1u, downloader.favicon_map()[favicon_url].size());
120 } 121 }
121 122
122 TEST_F(FaviconDownloaderTest, DownloadWithUrlsFromWebContentsNotification) { 123 TEST_F(FaviconDownloaderTest, DownloadWithUrlsFromWebContentsNotification) {
123 const GURL favicon_url("http://www.google.com/favicon.ico"); 124 const GURL favicon_url("http://www.google.com/favicon.ico");
124 TestFaviconDownloader downloader(web_contents(), std::vector<GURL>()); 125 TestFaviconDownloader downloader(web_contents(), std::vector<GURL>());
125 126
126 std::vector<content::FaviconURL> favicon_urls; 127 std::vector<content::FaviconURL> favicon_urls;
127 favicon_urls.push_back(content::FaviconURL( 128 favicon_urls.push_back(
128 favicon_url, content::FaviconURL::FAVICON, std::vector<gfx::Size>())); 129 content::FaviconURL(favicon_url, content::FaviconURL::IconType::kFavicon,
130 std::vector<gfx::Size>()));
129 EXPECT_EQ(0u, downloader.pending_requests()); 131 EXPECT_EQ(0u, downloader.pending_requests());
130 132
131 // Start downloader before favicon URLs are loaded. 133 // Start downloader before favicon URLs are loaded.
132 downloader.Start(); 134 downloader.Start();
133 EXPECT_EQ(0u, downloader.pending_requests()); 135 EXPECT_EQ(0u, downloader.pending_requests());
134 136
135 downloader.UpdateFaviconURLs(favicon_urls); 137 downloader.UpdateFaviconURLs(favicon_urls);
136 EXPECT_EQ(1u, downloader.pending_requests()); 138 EXPECT_EQ(1u, downloader.pending_requests());
137 139
138 std::vector<gfx::Size> sizes(1, gfx::Size(32, 32)); 140 std::vector<gfx::Size> sizes(1, gfx::Size(32, 32));
(...skipping 11 matching lines...) Expand all
150 152
151 std::vector<GURL> extra_urls; 153 std::vector<GURL> extra_urls;
152 // This should get downloaded. 154 // This should get downloaded.
153 extra_urls.push_back(favicon_url_2); 155 extra_urls.push_back(favicon_url_2);
154 // This is duplicated in the favicon urls and should only be downloaded once. 156 // This is duplicated in the favicon urls and should only be downloaded once.
155 extra_urls.push_back(empty_favicon); 157 extra_urls.push_back(empty_favicon);
156 158
157 TestFaviconDownloader downloader(web_contents(), extra_urls); 159 TestFaviconDownloader downloader(web_contents(), extra_urls);
158 std::vector<content::FaviconURL> favicon_urls; 160 std::vector<content::FaviconURL> favicon_urls;
159 favicon_urls.push_back(content::FaviconURL( 161 favicon_urls.push_back(content::FaviconURL(
160 favicon_url_1, content::FaviconURL::FAVICON, std::vector<gfx::Size>())); 162 favicon_url_1, content::FaviconURL::IconType::kFavicon,
163 std::vector<gfx::Size>()));
161 // This is duplicated in the favicon urls and should only be downloaded once. 164 // This is duplicated in the favicon urls and should only be downloaded once.
162 favicon_urls.push_back(content::FaviconURL( 165 favicon_urls.push_back(content::FaviconURL(
163 empty_favicon, content::FaviconURL::FAVICON, std::vector<gfx::Size>())); 166 empty_favicon, content::FaviconURL::IconType::kFavicon,
167 std::vector<gfx::Size>()));
164 // Invalid icons shouldn't get put into the download queue. 168 // Invalid icons shouldn't get put into the download queue.
165 favicon_urls.push_back( 169 favicon_urls.push_back(content::FaviconURL(
166 content::FaviconURL(GURL("http://www.google.com/invalid.ico"), 170 GURL("http://www.google.com/invalid.ico"),
167 content::FaviconURL::INVALID_ICON, 171 content::FaviconURL::IconType::kInvalid, std::vector<gfx::Size>()));
168 std::vector<gfx::Size>()));
169 downloader.set_initial_favicon_urls(favicon_urls); 172 downloader.set_initial_favicon_urls(favicon_urls);
170 downloader.Start(); 173 downloader.Start();
171 EXPECT_EQ(3u, downloader.pending_requests()); 174 EXPECT_EQ(3u, downloader.pending_requests());
172 175
173 std::vector<gfx::Size> sizes_1(1, gfx::Size(16, 16)); 176 std::vector<gfx::Size> sizes_1(1, gfx::Size(16, 16));
174 downloader.CompleteImageDownload(0, favicon_url_1, sizes_1); 177 downloader.CompleteImageDownload(0, favicon_url_1, sizes_1);
175 178
176 std::vector<gfx::Size> sizes_2; 179 std::vector<gfx::Size> sizes_2;
177 sizes_2.push_back(gfx::Size(32, 32)); 180 sizes_2.push_back(gfx::Size(32, 32));
178 sizes_2.push_back(gfx::Size(64, 64)); 181 sizes_2.push_back(gfx::Size(64, 64));
(...skipping 15 matching lines...) Expand all
194 const GURL favicon_url_2("http://www.google.com/favicon2.ico"); 197 const GURL favicon_url_2("http://www.google.com/favicon2.ico");
195 198
196 std::vector<GURL> extra_urls; 199 std::vector<GURL> extra_urls;
197 extra_urls.push_back(favicon_url_1); 200 extra_urls.push_back(favicon_url_1);
198 201
199 TestFaviconDownloader downloader(web_contents(), extra_urls); 202 TestFaviconDownloader downloader(web_contents(), extra_urls);
200 203
201 // This favicon URL should be ignored. 204 // This favicon URL should be ignored.
202 std::vector<content::FaviconURL> favicon_urls; 205 std::vector<content::FaviconURL> favicon_urls;
203 favicon_urls.push_back(content::FaviconURL( 206 favicon_urls.push_back(content::FaviconURL(
204 favicon_url_2, content::FaviconURL::FAVICON, std::vector<gfx::Size>())); 207 favicon_url_2, content::FaviconURL::IconType::kFavicon,
208 std::vector<gfx::Size>()));
205 downloader.set_initial_favicon_urls(favicon_urls); 209 downloader.set_initial_favicon_urls(favicon_urls);
206 downloader.SkipPageFavicons(); 210 downloader.SkipPageFavicons();
207 downloader.Start(); 211 downloader.Start();
208 EXPECT_EQ(1u, downloader.pending_requests()); 212 EXPECT_EQ(1u, downloader.pending_requests());
209 213
210 std::vector<gfx::Size> sizes_1(1, gfx::Size(16, 16)); 214 std::vector<gfx::Size> sizes_1(1, gfx::Size(16, 16));
211 downloader.CompleteImageDownload(0, favicon_url_1, sizes_1); 215 downloader.CompleteImageDownload(0, favicon_url_1, sizes_1);
212 216
213 // This download should not be finished and inserted into the map. 217 // This download should not be finished and inserted into the map.
214 std::vector<gfx::Size> sizes_2; 218 std::vector<gfx::Size> sizes_2;
215 sizes_2.push_back(gfx::Size(32, 32)); 219 sizes_2.push_back(gfx::Size(32, 32));
216 sizes_2.push_back(gfx::Size(64, 64)); 220 sizes_2.push_back(gfx::Size(64, 64));
217 downloader.CompleteImageDownload(1, favicon_url_2, sizes_2); 221 downloader.CompleteImageDownload(1, favicon_url_2, sizes_2);
218 EXPECT_EQ(0u, downloader.pending_requests()); 222 EXPECT_EQ(0u, downloader.pending_requests());
219 223
220 EXPECT_EQ(1u, downloader.favicon_map().size()); 224 EXPECT_EQ(1u, downloader.favicon_map().size());
221 EXPECT_EQ(1u, downloader.favicon_map()[favicon_url_1].size()); 225 EXPECT_EQ(1u, downloader.favicon_map()[favicon_url_1].size());
222 EXPECT_EQ(0u, downloader.favicon_map()[favicon_url_2].size()); 226 EXPECT_EQ(0u, downloader.favicon_map()[favicon_url_2].size());
223 } 227 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/favicon_downloader.cc ('k') | components/favicon/content/content_favicon_driver_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698