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

Unified Diff: components/favicon/core/favicon_handler_unittest.cc

Issue 2808063002: Add DownloadStatus metric to FaviconHandler (Closed)
Patch Set: Rebase 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/favicon/core/favicon_handler.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 e855508162435ebd488ad0229dc60db23986d55f..4a997f382474f3ff6783867958eccd253e6ccf70 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,10 @@ TEST_F(FaviconHandlerTest, TestRecordSingleFaviconDownloadAttempt) {
EXPECT_THAT(
histogram_tester.GetAllSamples("Favicons.DownloadAttempts.TouchIcons"),
IsEmpty());
+ EXPECT_THAT(
+ histogram_tester.GetAllSamples("Favicons.DownloadOutcome"),
+ ElementsAre(base::Bucket(static_cast<int>(DownloadOutcome::SUCCEEDED),
+ /*expected_count=*/1)));
}
TEST_F(FaviconHandlerTest, TestRecordSingleLargeIconDownloadAttempt) {
@@ -1089,6 +1094,10 @@ TEST_F(FaviconHandlerTest, TestRecordSingleLargeIconDownloadAttempt) {
EXPECT_THAT(
histogram_tester.GetAllSamples("Favicons.DownloadAttempts.TouchIcons"),
IsEmpty());
+ EXPECT_THAT(
+ histogram_tester.GetAllSamples("Favicons.DownloadOutcome"),
+ ElementsAre(base::Bucket(static_cast<int>(DownloadOutcome::SUCCEEDED),
+ /*expected_count=*/1)));
}
TEST_F(FaviconHandlerTest, TestRecordSingleTouchIconDownloadAttempt) {
@@ -1106,6 +1115,10 @@ 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(static_cast<int>(DownloadOutcome::SUCCEEDED),
+ /*expected_count=*/1)));
}
TEST_F(FaviconHandlerTest, TestRecordDownloadAttemptsFinishedByCache) {
@@ -1148,5 +1161,36 @@ TEST_F(FaviconHandlerTest, TestRecordSingleDownloadAttemptForRefreshingIcons) {
ElementsAre(base::Bucket(/*sample=*/1, /*expected_count=*/1)));
}
+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(static_cast<int>(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(static_cast<int>(DownloadOutcome::SKIPPED),
+ /*expected_count=*/1)));
+}
+
} // namespace
} // namespace favicon
« no previous file with comments | « components/favicon/core/favicon_handler.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698