Index: components/favicon/core/favicon_handler_unittest.cc |
diff --git a/components/favicon/core/favicon_handler_unittest.cc b/components/favicon/core/favicon_handler_unittest.cc |
index 42afccc34f094eec7df2a37c4ca7a28bcde7670b..9f9d0ccd117feb960ccd695973b6db7c1e105f42 100644 |
--- a/components/favicon/core/favicon_handler_unittest.cc |
+++ b/components/favicon/core/favicon_handler_unittest.cc |
@@ -42,6 +42,7 @@ using testing::IsEmpty; |
using testing::Return; |
using testing::_; |
+using DownloadOutcome = FaviconHandler::DownloadOutcome; |
using IntVector = std::vector<int>; |
using URLVector = std::vector<GURL>; |
using BitmapVector = std::vector<SkBitmap>; |
@@ -1072,6 +1073,9 @@ TEST_F(FaviconHandlerTest, TestRecordSingleFaviconDownloadAttempt) { |
EXPECT_THAT( |
histogram_tester.GetAllSamples("Favicons.DownloadAttempts.TouchIcons"), |
IsEmpty()); |
+ EXPECT_THAT(histogram_tester.GetAllSamples("Favicons.DownloadOutcome"), |
+ ElementsAre(base::Bucket(DownloadOutcome::SUCCEEDED, |
+ /*expected_count=*/1))); |
} |
TEST_F(FaviconHandlerTest, TestRecordSingleLargeIconDownloadAttempt) { |
@@ -1089,6 +1093,9 @@ TEST_F(FaviconHandlerTest, TestRecordSingleLargeIconDownloadAttempt) { |
EXPECT_THAT( |
histogram_tester.GetAllSamples("Favicons.DownloadAttempts.TouchIcons"), |
IsEmpty()); |
+ EXPECT_THAT(histogram_tester.GetAllSamples("Favicons.DownloadOutcome"), |
+ ElementsAre(base::Bucket(DownloadOutcome::SUCCEEDED, |
+ /*expected_count=*/1))); |
} |
TEST_F(FaviconHandlerTest, TestRecordSingleTouchIconDownloadAttempt) { |
@@ -1106,6 +1113,9 @@ TEST_F(FaviconHandlerTest, TestRecordSingleTouchIconDownloadAttempt) { |
EXPECT_THAT( |
histogram_tester.GetAllSamples("Favicons.DownloadAttempts.TouchIcons"), |
ElementsAre(base::Bucket(/*sample=*/1, /*expected_count=*/1))); |
+ EXPECT_THAT(histogram_tester.GetAllSamples("Favicons.DownloadOutcome"), |
+ ElementsAre(base::Bucket(DownloadOutcome::SUCCEEDED, |
+ /*expected_count=*/1))); |
} |
TEST_F(FaviconHandlerTest, TestRecordDownloadAttemptsFinishedByCache) { |
@@ -1135,5 +1145,34 @@ TEST_F(FaviconHandlerTest, TestRecordDownloadAttemptsFinishedByCache) { |
IsEmpty()); |
} |
+TEST_F(FaviconHandlerTest, TestRecordFailingDownloadAttempt) { |
+ base::HistogramTester histogram_tester; |
+ const GURL k404IconURL("http://www.google.com/404.png"); |
+ |
+ delegate_.fake_downloader().AddError(k404IconURL, 404); |
+ |
+ EXPECT_CALL(favicon_service_, UnableToDownloadFavicon(k404IconURL)); |
+ |
+ RunHandlerWithSimpleFaviconCandidates({k404IconURL}); |
+ |
+ EXPECT_THAT( |
+ histogram_tester.GetAllSamples("Favicons.DownloadOutcome"), |
+ ElementsAre(base::Bucket(DownloadOutcome::FAILED, /*expected_count=*/1))); |
+} |
+ |
+TEST_F(FaviconHandlerTest, TestRecordSkippedDownloadForKnownFailingUrl) { |
+ base::HistogramTester histogram_tester; |
+ const GURL k404IconURL("http://www.google.com/404.png"); |
+ |
+ ON_CALL(favicon_service_, WasUnableToDownloadFavicon(k404IconURL)) |
+ .WillByDefault(Return(true)); |
+ |
+ RunHandlerWithSimpleFaviconCandidates({k404IconURL}); |
+ |
+ EXPECT_THAT(histogram_tester.GetAllSamples("Favicons.DownloadOutcome"), |
+ ElementsAre(base::Bucket(DownloadOutcome::SKIPPED, |
+ /*expected_count=*/1))); |
+} |
+ |
} // namespace |
} // namespace favicon |