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

Side by Side Diff: components/favicon/core/favicon_handler_unittest.cc

Issue 2823093002: Make FaviconService::GetRawFaviconForPageURL() select the best candidate among all the icon types (Closed)
Patch Set: Merge branch 'master' into icon_type Created 3 years, 8 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 (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 "components/favicon/core/favicon_handler.h" 5 #include "components/favicon/core/favicon_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <map> 9 #include <map>
10 #include <memory> 10 #include <memory>
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 const GURL& page_url, 254 const GURL& page_url,
255 int icon_types, 255 int icon_types,
256 int desired_size_in_dip, 256 int desired_size_in_dip,
257 const favicon_base::FaviconResultsCallback& callback, 257 const favicon_base::FaviconResultsCallback& callback,
258 base::CancelableTaskTracker* tracker) { 258 base::CancelableTaskTracker* tracker) {
259 return GetFaviconForPageOrIconURL(page_url, callback, tracker); 259 return GetFaviconForPageOrIconURL(page_url, callback, tracker);
260 } 260 }
261 261
262 base::CancelableTaskTracker::TaskId UpdateFaviconMappingsAndFetch( 262 base::CancelableTaskTracker::TaskId UpdateFaviconMappingsAndFetch(
263 const GURL& page_url, 263 const GURL& page_url,
264 const std::vector<GURL>& icon_urls, 264 const GURL& icon_url,
265 int icon_types, 265 favicon_base::IconType icon_type,
mastiz 2017/04/18 08:04:34 This signature change is orthogonal. Can you pleas
pkotwicz 2017/04/20 04:06:19 Done.
266 int desired_size_in_dip, 266 int desired_size_in_dip,
267 const favicon_base::FaviconResultsCallback& callback, 267 const favicon_base::FaviconResultsCallback& callback,
268 base::CancelableTaskTracker* tracker) { 268 base::CancelableTaskTracker* tracker) {
269 CHECK_EQ(1U, icon_urls.size()) << "Multi-icon lookup not implemented"; 269 return GetFaviconForPageOrIconURL(icon_url, callback, tracker);
270 return GetFaviconForPageOrIconURL(icon_urls.front(), callback, tracker);
271 } 270 }
272 271
273 private: 272 private:
274 base::CancelableTaskTracker::TaskId GetFaviconForPageOrIconURL( 273 base::CancelableTaskTracker::TaskId GetFaviconForPageOrIconURL(
275 const GURL& page_or_icon_url, 274 const GURL& page_or_icon_url,
276 const favicon_base::FaviconResultsCallback& callback, 275 const favicon_base::FaviconResultsCallback& callback,
277 base::CancelableTaskTracker* tracker) { 276 base::CancelableTaskTracker* tracker) {
278 db_requests_.push_back(page_or_icon_url); 277 db_requests_.push_back(page_or_icon_url);
279 278
280 return tracker->PostTask(base::ThreadTaskRunnerHandle::Get().get(), 279 return tracker->PostTask(base::ThreadTaskRunnerHandle::Get().get(),
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 kPageURL, FaviconDriverObserver::NON_TOUCH_16_DIP, 390 kPageURL, FaviconDriverObserver::NON_TOUCH_16_DIP,
392 kIconURL, /*icon_url_changed=*/true, _)); 391 kIconURL, /*icon_url_changed=*/true, _));
393 392
394 RunHandlerWithSimpleFaviconCandidates({kIconURL}); 393 RunHandlerWithSimpleFaviconCandidates({kIconURL});
395 EXPECT_THAT(delegate_.downloads(), IsEmpty()); 394 EXPECT_THAT(delegate_.downloads(), IsEmpty());
396 } 395 }
397 396
398 // Test that UpdateFaviconsAndFetch() is called with the appropriate parameters 397 // Test that UpdateFaviconsAndFetch() is called with the appropriate parameters
399 // when there is data in the database for neither the page URL nor the icon URL. 398 // when there is data in the database for neither the page URL nor the icon URL.
400 TEST_F(FaviconHandlerTest, UpdateFaviconMappingsAndFetch) { 399 TEST_F(FaviconHandlerTest, UpdateFaviconMappingsAndFetch) {
401 EXPECT_CALL(favicon_service_, UpdateFaviconMappingsAndFetch( 400 EXPECT_CALL(favicon_service_,
402 kPageURL, URLVector{kIconURL16x16}, FAVICON, 401 UpdateFaviconMappingsAndFetch(kPageURL, kIconURL16x16, FAVICON,
403 /*desired_size_in_dip=*/16, _, _)); 402 /*desired_size_in_dip=*/16, _, _));
404 403
405 RunHandlerWithSimpleFaviconCandidates({kIconURL16x16}); 404 RunHandlerWithSimpleFaviconCandidates({kIconURL16x16});
406 } 405 }
407 406
408 // Test that the FaviconHandler process finishes when: 407 // Test that the FaviconHandler process finishes when:
409 // - There is data in the database for neither the page URL nor the icon URL. 408 // - There is data in the database for neither the page URL nor the icon URL.
410 // AND 409 // AND
411 // - FaviconService::GetFaviconForPageURL() callback returns before 410 // - FaviconService::GetFaviconForPageURL() callback returns before
412 // FaviconHandler::OnUpdateFaviconURL() is called. 411 // FaviconHandler::OnUpdateFaviconURL() is called.
413 TEST_F(FaviconHandlerTest, DownloadUnknownFaviconIfCandidatesSlower) { 412 TEST_F(FaviconHandlerTest, DownloadUnknownFaviconIfCandidatesSlower) {
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after
1026 1025
1027 RunHandlerWithCandidates( 1026 RunHandlerWithCandidates(
1028 FaviconDriverObserver::NON_TOUCH_LARGEST, 1027 FaviconDriverObserver::NON_TOUCH_LARGEST,
1029 {FaviconURL(kIconURL10x10, FAVICON, SizeVector{gfx::Size(16, 16)}), 1028 {FaviconURL(kIconURL10x10, FAVICON, SizeVector{gfx::Size(16, 16)}),
1030 FaviconURL(kIconURL12x12, FAVICON, SizeVector{gfx::Size(15, 15)}), 1029 FaviconURL(kIconURL12x12, FAVICON, SizeVector{gfx::Size(15, 15)}),
1031 FaviconURL(kIconURL16x16, FAVICON, kEmptySizes)}); 1030 FaviconURL(kIconURL16x16, FAVICON, kEmptySizes)});
1032 } 1031 }
1033 1032
1034 } // namespace 1033 } // namespace
1035 } // namespace favicon 1034 } // namespace favicon
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698