| 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 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 682 EXPECT_CALL(favicon_service_, SetFavicons(_, _, _, _)).Times(0); | 682 EXPECT_CALL(favicon_service_, SetFavicons(_, _, _, _)).Times(0); |
| 683 | 683 |
| 684 EXPECT_CALL(delegate_, OnFaviconUpdated(_, _, kIconURL16x16, _, _)); | 684 EXPECT_CALL(delegate_, OnFaviconUpdated(_, _, kIconURL16x16, _, _)); |
| 685 | 685 |
| 686 RunHandlerWithSimpleFaviconCandidates({kIconURL16x16}); | 686 RunHandlerWithSimpleFaviconCandidates({kIconURL16x16}); |
| 687 EXPECT_THAT(delegate_.downloads(), ElementsAre(kIconURL16x16)); | 687 EXPECT_THAT(delegate_.downloads(), ElementsAre(kIconURL16x16)); |
| 688 EXPECT_THAT(favicon_service_.fake()->db_requests(), | 688 EXPECT_THAT(favicon_service_.fake()->db_requests(), |
| 689 ElementsAre(kPageURL, kIconURL16x16)); | 689 ElementsAre(kPageURL, kIconURL16x16)); |
| 690 } | 690 } |
| 691 | 691 |
| 692 // Test that the FaviconHandler saves a favicon if the page is bookmarked, even | |
| 693 // in incognito. | |
| 694 TEST_F(FaviconHandlerTest, DownloadBookmarkedFaviconInIncognito) { | |
| 695 ON_CALL(delegate_, IsOffTheRecord()).WillByDefault(Return(true)); | |
| 696 ON_CALL(delegate_, IsBookmarked(kPageURL)).WillByDefault(Return(true)); | |
| 697 | |
| 698 EXPECT_CALL(favicon_service_, UpdateFaviconMappingsAndFetch(_, _, _, _, _, _)) | |
| 699 .Times(0); | |
| 700 | |
| 701 EXPECT_CALL(favicon_service_, SetFavicons(_, kIconURL16x16, _, _)); | |
| 702 | |
| 703 RunHandlerWithSimpleFaviconCandidates({kIconURL16x16}); | |
| 704 EXPECT_THAT(delegate_.downloads(), ElementsAre(kIconURL16x16)); | |
| 705 } | |
| 706 | |
| 707 // Test that the icon is redownloaded if the icon cached for the page URL | 692 // Test that the icon is redownloaded if the icon cached for the page URL |
| 708 // expired. | 693 // expired. |
| 709 TEST_F(FaviconHandlerTest, RedownloadExpiredPageUrlFavicon) { | 694 TEST_F(FaviconHandlerTest, RedownloadExpiredPageUrlFavicon) { |
| 710 const GURL kIconURL("http://www.google.com/favicon"); | 695 const GURL kIconURL("http://www.google.com/favicon"); |
| 711 const SkColor kOldColor = SK_ColorBLUE; | 696 const SkColor kOldColor = SK_ColorBLUE; |
| 712 const SkColor kNewColor = SK_ColorGREEN; | 697 const SkColor kNewColor = SK_ColorGREEN; |
| 713 | 698 |
| 714 favicon_service_.fake()->Store( | 699 favicon_service_.fake()->Store( |
| 715 kPageURL, kIconURL, | 700 kPageURL, kIconURL, |
| 716 CreateRawBitmapResult(kIconURL, FAVICON, /*expired=*/true, | 701 CreateRawBitmapResult(kIconURL, FAVICON, /*expired=*/true, |
| (...skipping 1396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2113 | 2098 |
| 2114 // Complete the download. | 2099 // Complete the download. |
| 2115 EXPECT_CALL(favicon_service_, SetFavicons(_, kManifestURL2, _, _)); | 2100 EXPECT_CALL(favicon_service_, SetFavicons(_, kManifestURL2, _, _)); |
| 2116 EXPECT_CALL(delegate_, OnFaviconUpdated(_, _, kManifestURL2, _, _)); | 2101 EXPECT_CALL(delegate_, OnFaviconUpdated(_, _, kManifestURL2, _, _)); |
| 2117 EXPECT_TRUE(delegate_.fake_image_downloader().RunCallbackManually()); | 2102 EXPECT_TRUE(delegate_.fake_image_downloader().RunCallbackManually()); |
| 2118 base::RunLoop().RunUntilIdle(); | 2103 base::RunLoop().RunUntilIdle(); |
| 2119 } | 2104 } |
| 2120 | 2105 |
| 2121 } // namespace | 2106 } // namespace |
| 2122 } // namespace favicon | 2107 } // namespace favicon |
| OLD | NEW |