OLD | NEW |
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 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 EXPECT_CALL(favicon_service_, SetFavicons(_, _, _, _)).Times(0); | 460 EXPECT_CALL(favicon_service_, SetFavicons(_, _, _, _)).Times(0); |
461 | 461 |
462 EXPECT_CALL(delegate_, OnFaviconUpdated(_, _, kIconURL16x16, _, _)); | 462 EXPECT_CALL(delegate_, OnFaviconUpdated(_, _, kIconURL16x16, _, _)); |
463 | 463 |
464 RunHandlerWithSimpleFaviconCandidates({kIconURL16x16}); | 464 RunHandlerWithSimpleFaviconCandidates({kIconURL16x16}); |
465 EXPECT_THAT(delegate_.downloads(), ElementsAre(kIconURL16x16)); | 465 EXPECT_THAT(delegate_.downloads(), ElementsAre(kIconURL16x16)); |
466 EXPECT_THAT(favicon_service_.fake()->db_requests(), | 466 EXPECT_THAT(favicon_service_.fake()->db_requests(), |
467 ElementsAre(kPageURL, kIconURL16x16)); | 467 ElementsAre(kPageURL, kIconURL16x16)); |
468 } | 468 } |
469 | 469 |
| 470 // Test that the FaviconHandler saves a favicon if the page is bookmarked, even |
| 471 // in incognito. |
| 472 TEST_F(FaviconHandlerTest, DownloadBookmarkedFaviconInIncognito) { |
| 473 ON_CALL(delegate_, IsOffTheRecord()).WillByDefault(Return(true)); |
| 474 ON_CALL(delegate_, IsBookmarked(kPageURL)).WillByDefault(Return(true)); |
| 475 |
| 476 EXPECT_CALL(favicon_service_, UpdateFaviconMappingsAndFetch(_, _, _, _, _, _)) |
| 477 .Times(0); |
| 478 |
| 479 EXPECT_CALL(favicon_service_, SetFavicons(_, kIconURL16x16, _, _)); |
| 480 |
| 481 RunHandlerWithSimpleFaviconCandidates({kIconURL16x16}); |
| 482 EXPECT_THAT(delegate_.downloads(), ElementsAre(kIconURL16x16)); |
| 483 } |
| 484 |
470 // Test that the icon is redownloaded if the icon cached for the page URL | 485 // Test that the icon is redownloaded if the icon cached for the page URL |
471 // expired. | 486 // expired. |
472 TEST_F(FaviconHandlerTest, RedownloadExpiredPageUrlFavicon) { | 487 TEST_F(FaviconHandlerTest, RedownloadExpiredPageUrlFavicon) { |
473 favicon_service_.fake()->Store( | 488 favicon_service_.fake()->Store( |
474 kPageURL, kIconURL16x16, | 489 kPageURL, kIconURL16x16, |
475 CreateRawBitmapResult(kIconURL16x16, FAVICON, /*expired=*/true)); | 490 CreateRawBitmapResult(kIconURL16x16, FAVICON, /*expired=*/true)); |
476 | 491 |
477 // TODO(crbug.com/700811): It would be nice if we could check whether the two | 492 // TODO(crbug.com/700811): It would be nice if we could check whether the two |
478 // OnFaviconUpdated() calls are called with different gfx::Images (as opposed | 493 // OnFaviconUpdated() calls are called with different gfx::Images (as opposed |
479 // to calling OnFaviconUpdated() with the expired gfx::Image both times). | 494 // to calling OnFaviconUpdated() with the expired gfx::Image both times). |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1006 | 1021 |
1007 RunHandlerWithCandidates( | 1022 RunHandlerWithCandidates( |
1008 FaviconDriverObserver::NON_TOUCH_LARGEST, | 1023 FaviconDriverObserver::NON_TOUCH_LARGEST, |
1009 {FaviconURL(kIconURL10x10, FAVICON, SizeVector{gfx::Size(16, 16)}), | 1024 {FaviconURL(kIconURL10x10, FAVICON, SizeVector{gfx::Size(16, 16)}), |
1010 FaviconURL(kIconURL12x12, FAVICON, SizeVector{gfx::Size(15, 15)}), | 1025 FaviconURL(kIconURL12x12, FAVICON, SizeVector{gfx::Size(15, 15)}), |
1011 FaviconURL(kIconURL16x16, FAVICON, kEmptySizes)}); | 1026 FaviconURL(kIconURL16x16, FAVICON, kEmptySizes)}); |
1012 } | 1027 } |
1013 | 1028 |
1014 } // namespace | 1029 } // namespace |
1015 } // namespace favicon | 1030 } // namespace favicon |
OLD | NEW |