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

Unified Diff: components/favicon/content/content_favicon_driver_unittest.cc

Issue 2710953002: Add metrics for quantity and type of Favicon candidates (Closed)
Patch Set: Adress comments Created 3 years, 10 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/content/BUILD.gn ('k') | components/favicon/core/favicon_driver_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/favicon/content/content_favicon_driver_unittest.cc
diff --git a/components/favicon/content/content_favicon_driver_unittest.cc b/components/favicon/content/content_favicon_driver_unittest.cc
index d1ede99adfffb8888b2b18cecbb4c564245131ae..73769c5f2f222429a58d1a09df570d5584f7127b 100644
--- a/components/favicon/content/content_favicon_driver_unittest.cc
+++ b/components/favicon/content/content_favicon_driver_unittest.cc
@@ -9,6 +9,7 @@
#include "base/macros.h"
#include "base/run_loop.h"
+#include "base/test/histogram_tester.h"
#include "components/favicon/core/favicon_client.h"
#include "components/favicon/core/favicon_handler.h"
#include "components/favicon/core/test/mock_favicon_service.h"
@@ -24,6 +25,7 @@
namespace favicon {
namespace {
+using testing::ElementsAre;
using testing::Return;
using testing::_;
@@ -135,9 +137,9 @@ TEST_F(ContentFaviconDriverTest, FaviconUpdateNoLastCommittedEntry) {
ASSERT_EQ(nullptr, web_contents()->GetController().GetLastCommittedEntry());
std::vector<content::FaviconURL> favicon_urls;
- favicon_urls.push_back(content::FaviconURL(
- GURL("http://www.google.ca/favicon.ico"), content::FaviconURL::FAVICON,
- std::vector<gfx::Size>()));
+ favicon_urls.push_back(
+ content::FaviconURL(GURL("http://www.google.ca/favicon.ico"),
+ content::FaviconURL::FAVICON, kEmptyIconSizes));
favicon::ContentFaviconDriver* driver =
favicon::ContentFaviconDriver::FromWebContents(web_contents());
static_cast<content::WebContentsObserver*>(driver)
@@ -147,5 +149,49 @@ TEST_F(ContentFaviconDriverTest, FaviconUpdateNoLastCommittedEntry) {
EXPECT_TRUE(driver->favicon_urls().empty());
}
+TEST_F(ContentFaviconDriverTest, RecordsHistorgramsForCandidates) {
+ const std::vector<gfx::Size> kSizes16x16and32x32({{16, 16}, {32, 32}});
+ base::HistogramTester tester;
+ content::WebContentsObserver* driver_as_observer =
+ ContentFaviconDriver::FromWebContents(web_contents());
+
+ // Navigation to a page updating one icon.
+ NavigateAndCommit(GURL("http://www.youtube.com"));
+ driver_as_observer->DidUpdateFaviconURL(
+ {content::FaviconURL(GURL("http://www.youtube.com/favicon.ico"),
+ content::FaviconURL::FAVICON, kSizes16x16and32x32)});
+
+ EXPECT_THAT(tester.GetAllSamples("Favicons.CandidatesCount"),
+ ElementsAre(base::Bucket(/*min=*/1, /*count=*/1)));
+ EXPECT_THAT(tester.GetAllSamples("Favicons.CandidatesWithDefinedSizesCount"),
+ ElementsAre(base::Bucket(/*min=*/1, /*count=*/1)));
+ EXPECT_THAT(tester.GetAllSamples("Favicons.CandidatesWithTouchIconsCount"),
+ ElementsAre(base::Bucket(/*min=*/0, /*count=*/1)));
+
+ std::vector<content::FaviconURL> favicon_urls = {
+ content::FaviconURL(GURL("http://www.google.ca/favicon.ico"),
+ content::FaviconURL::FAVICON, kSizes16x16and32x32),
+ content::FaviconURL(GURL("http://www.google.ca/precomposed_icon.png"),
+ content::FaviconURL::TOUCH_PRECOMPOSED_ICON,
+ kEmptyIconSizes),
+ content::FaviconURL(GURL("http://www.google.ca/touch_icon.png"),
+ content::FaviconURL::TOUCH_ICON, kEmptyIconSizes)};
+
+ // Double navigation to a page with 3 different icons.
+ NavigateAndCommit(GURL("http://www.google.ca"));
+ driver_as_observer->DidUpdateFaviconURL(favicon_urls);
+ NavigateAndCommit(GURL("http://www.google.ca"));
+ driver_as_observer->DidUpdateFaviconURL(favicon_urls);
+
+ EXPECT_THAT(tester.GetAllSamples("Favicons.CandidatesCount"),
+ ElementsAre(base::Bucket(/*min=*/1, /*count=*/1),
+ base::Bucket(/*min=*/3, /*count=*/2)));
+ EXPECT_THAT(tester.GetAllSamples("Favicons.CandidatesWithDefinedSizesCount"),
+ ElementsAre(base::Bucket(/*min=*/1, /*count=*/3)));
+ EXPECT_THAT(tester.GetAllSamples("Favicons.CandidatesWithTouchIconsCount"),
+ ElementsAre(base::Bucket(/*min=*/0, /*count=*/1),
+ base::Bucket(/*min=*/2, /*count=*/2)));
+}
+
} // namespace
} // namespace favicon
« no previous file with comments | « components/favicon/content/BUILD.gn ('k') | components/favicon/core/favicon_driver_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698