| 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 1442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1453 .WillByDefault(Return(true)); | 1453 .WillByDefault(Return(true)); |
| 1454 | 1454 |
| 1455 RunHandlerWithSimpleFaviconCandidates({k404IconURL}); | 1455 RunHandlerWithSimpleFaviconCandidates({k404IconURL}); |
| 1456 | 1456 |
| 1457 EXPECT_THAT( | 1457 EXPECT_THAT( |
| 1458 histogram_tester.GetAllSamples("Favicons.DownloadOutcome"), | 1458 histogram_tester.GetAllSamples("Favicons.DownloadOutcome"), |
| 1459 ElementsAre(base::Bucket(static_cast<int>(DownloadOutcome::SKIPPED), | 1459 ElementsAre(base::Bucket(static_cast<int>(DownloadOutcome::SKIPPED), |
| 1460 /*expected_count=*/1))); | 1460 /*expected_count=*/1))); |
| 1461 } | 1461 } |
| 1462 | 1462 |
| 1463 // Test that the support for Web Manifest is disabled by default, unless the | 1463 // Test that the feature for loading icons from Web Manifests can be disabled. |
| 1464 // feature is enabled. | 1464 TEST_F(FaviconHandlerTest, IgnoreWebManifest) { |
| 1465 TEST_F(FaviconHandlerTest, IgnoreWebManifestByDefault) { | |
| 1466 const GURL kManifestURL("http://www.google.com/manifest.json"); | 1465 const GURL kManifestURL("http://www.google.com/manifest.json"); |
| 1466 base::test::ScopedFeatureList override_features; |
| 1467 override_features.InitAndDisableFeature(kFaviconsFromWebManifest); |
| 1467 | 1468 |
| 1468 RunHandlerWithSimpleFaviconCandidates({kIconURL16x16}, kManifestURL); | 1469 RunHandlerWithSimpleFaviconCandidates({kIconURL16x16}, kManifestURL); |
| 1469 EXPECT_THAT(favicon_service_.fake()->db_requests(), | 1470 EXPECT_THAT(favicon_service_.fake()->db_requests(), |
| 1470 Not(Contains(kManifestURL))); | 1471 Not(Contains(kManifestURL))); |
| 1471 EXPECT_THAT(delegate_.downloads(), Not(Contains(kManifestURL))); | 1472 EXPECT_THAT(delegate_.downloads(), Not(Contains(kManifestURL))); |
| 1472 } | 1473 } |
| 1473 | 1474 |
| 1475 // Manifests are currently enabled by default. Leaving this fixture for |
| 1476 // logical grouping and blame layer. |
| 1474 class FaviconHandlerManifestsEnabledTest : public FaviconHandlerTest { | 1477 class FaviconHandlerManifestsEnabledTest : public FaviconHandlerTest { |
| 1475 protected: | 1478 protected: |
| 1476 const GURL kManifestURL = GURL("http://www.google.com/manifest.json"); | 1479 const GURL kManifestURL = GURL("http://www.google.com/manifest.json"); |
| 1477 | 1480 |
| 1478 FaviconHandlerManifestsEnabledTest() { | 1481 FaviconHandlerManifestsEnabledTest() = default; |
| 1479 override_features_.InitAndEnableFeature(kFaviconsFromWebManifest); | |
| 1480 } | |
| 1481 | 1482 |
| 1482 private: | 1483 private: |
| 1483 base::test::ScopedFeatureList override_features_; | |
| 1484 | |
| 1485 DISALLOW_COPY_AND_ASSIGN(FaviconHandlerManifestsEnabledTest); | 1484 DISALLOW_COPY_AND_ASSIGN(FaviconHandlerManifestsEnabledTest); |
| 1486 }; | 1485 }; |
| 1487 | 1486 |
| 1488 // Test that a favicon corresponding to a web manifest is reported when: | 1487 // Test that a favicon corresponding to a web manifest is reported when: |
| 1489 // - There is data in the favicon database for the manifest URL. | 1488 // - There is data in the favicon database for the manifest URL. |
| 1490 // AND | 1489 // AND |
| 1491 // - FaviconService::OnFaviconDataForManifestFromFaviconService() runs before | 1490 // - FaviconService::OnFaviconDataForManifestFromFaviconService() runs before |
| 1492 // FaviconHandler::OnUpdateCandidates() is called. | 1491 // FaviconHandler::OnUpdateCandidates() is called. |
| 1493 TEST_F(FaviconHandlerManifestsEnabledTest, | 1492 TEST_F(FaviconHandlerManifestsEnabledTest, |
| 1494 GetFaviconFromManifestInHistoryIfCandidatesSlower) { | 1493 GetFaviconFromManifestInHistoryIfCandidatesSlower) { |
| (...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1966 | 1965 |
| 1967 // Complete the download. | 1966 // Complete the download. |
| 1968 EXPECT_CALL(favicon_service_, SetFavicons(_, kManifestURL2, _, _)); | 1967 EXPECT_CALL(favicon_service_, SetFavicons(_, kManifestURL2, _, _)); |
| 1969 EXPECT_CALL(delegate_, OnFaviconUpdated(_, _, kManifestURL2, _, _)); | 1968 EXPECT_CALL(delegate_, OnFaviconUpdated(_, _, kManifestURL2, _, _)); |
| 1970 EXPECT_TRUE(delegate_.fake_image_downloader().RunCallbackManually()); | 1969 EXPECT_TRUE(delegate_.fake_image_downloader().RunCallbackManually()); |
| 1971 base::RunLoop().RunUntilIdle(); | 1970 base::RunLoop().RunUntilIdle(); |
| 1972 } | 1971 } |
| 1973 | 1972 |
| 1974 } // namespace | 1973 } // namespace |
| 1975 } // namespace favicon | 1974 } // namespace favicon |
| OLD | NEW |