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

Unified Diff: chrome/browser/engagement/site_engagement_service_unittest.cc

Issue 1427913002: Implement media playing engagement detection for the site engagement service. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@user-input-event
Patch Set: Addressing nits Created 5 years, 1 month 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 | « chrome/browser/engagement/site_engagement_service.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: chrome/browser/engagement/site_engagement_service_unittest.cc
diff --git a/chrome/browser/engagement/site_engagement_service_unittest.cc b/chrome/browser/engagement/site_engagement_service_unittest.cc
index 3debc8a06ffa537854afd34cf6d8d34725e7c8f7..e1825982796f12668ceee8a9a03f6caf79179040 100644
--- a/chrome/browser/engagement/site_engagement_service_unittest.cc
+++ b/chrome/browser/engagement/site_engagement_service_unittest.cc
@@ -506,6 +506,13 @@ TEST_F(SiteEngagementServiceTest, GetTotalUserInputPoints) {
service->HandleUserInput(url1, SiteEngagementMetrics::ENGAGEMENT_MOUSE);
EXPECT_DOUBLE_EQ(0.15, service->GetScore(url1));
EXPECT_DOUBLE_EQ(0.3, service->GetTotalEngagementPoints());
+
+ service->HandleUserInput(url2, SiteEngagementMetrics::ENGAGEMENT_WHEEL);
+ service->HandleUserInput(url3,
+ SiteEngagementMetrics::ENGAGEMENT_TOUCH_GESTURE);
+ EXPECT_DOUBLE_EQ(0.15, service->GetScore(url2));
+ EXPECT_DOUBLE_EQ(0.1, service->GetScore(url3));
+ EXPECT_DOUBLE_EQ(0.4, service->GetTotalEngagementPoints());
}
TEST_F(SiteEngagementServiceTest, CheckHistograms) {
@@ -546,6 +553,7 @@ TEST_F(SiteEngagementServiceTest, CheckHistograms) {
service->HandleNavigation(url1, ui::PAGE_TRANSITION_TYPED);
service->HandleUserInput(url1, SiteEngagementMetrics::ENGAGEMENT_KEYPRESS);
service->HandleUserInput(url1, SiteEngagementMetrics::ENGAGEMENT_MOUSE);
+ service->HandleMediaPlaying(url2, true);
histograms.ExpectTotalCount(SiteEngagementMetrics::kTotalEngagementHistogram,
1);
@@ -565,13 +573,16 @@ TEST_F(SiteEngagementServiceTest, CheckHistograms) {
histograms.ExpectUniqueSample(
SiteEngagementMetrics::kPercentOriginsWithMaxEngagementHistogram, 0, 1);
histograms.ExpectTotalCount(SiteEngagementMetrics::kEngagementTypeHistogram,
- 3);
+ 4);
histograms.ExpectBucketCount(SiteEngagementMetrics::kEngagementTypeHistogram,
SiteEngagementMetrics::ENGAGEMENT_NAVIGATION, 1);
histograms.ExpectBucketCount(SiteEngagementMetrics::kEngagementTypeHistogram,
SiteEngagementMetrics::ENGAGEMENT_KEYPRESS, 1);
histograms.ExpectBucketCount(SiteEngagementMetrics::kEngagementTypeHistogram,
SiteEngagementMetrics::ENGAGEMENT_MOUSE, 1);
+ histograms.ExpectBucketCount(SiteEngagementMetrics::kEngagementTypeHistogram,
+ SiteEngagementMetrics::ENGAGEMENT_MEDIA_HIDDEN,
+ 1);
clock->SetNow(GetReferenceTime() + base::TimeDelta::FromMinutes(59));
@@ -579,18 +590,23 @@ TEST_F(SiteEngagementServiceTest, CheckHistograms) {
service->HandleNavigation(url2, ui::PAGE_TRANSITION_AUTO_BOOKMARK);
histograms.ExpectTotalCount(SiteEngagementMetrics::kEngagementTypeHistogram,
- 5);
+ 6);
histograms.ExpectBucketCount(SiteEngagementMetrics::kEngagementTypeHistogram,
SiteEngagementMetrics::ENGAGEMENT_NAVIGATION, 3);
histograms.ExpectBucketCount(SiteEngagementMetrics::kEngagementTypeHistogram,
SiteEngagementMetrics::ENGAGEMENT_KEYPRESS, 1);
histograms.ExpectBucketCount(SiteEngagementMetrics::kEngagementTypeHistogram,
SiteEngagementMetrics::ENGAGEMENT_MOUSE, 1);
+ histograms.ExpectBucketCount(SiteEngagementMetrics::kEngagementTypeHistogram,
+ SiteEngagementMetrics::ENGAGEMENT_MEDIA_HIDDEN,
+ 1);
clock->SetNow(GetReferenceTime() + base::TimeDelta::FromMinutes(60));
service->HandleNavigation(url3, ui::PAGE_TRANSITION_TYPED);
- service->HandleUserInput(url2, SiteEngagementMetrics::ENGAGEMENT_MOUSE);
+ service->HandleUserInput(url2,
+ SiteEngagementMetrics::ENGAGEMENT_TOUCH_GESTURE);
+ service->HandleMediaPlaying(url3, false);
histograms.ExpectTotalCount(SiteEngagementMetrics::kTotalEngagementHistogram,
2);
@@ -612,28 +628,42 @@ TEST_F(SiteEngagementServiceTest, CheckHistograms) {
histograms.ExpectUniqueSample(
SiteEngagementMetrics::kPercentOriginsWithMaxEngagementHistogram, 0, 2);
histograms.ExpectTotalCount(SiteEngagementMetrics::kEngagementTypeHistogram,
- 7);
+ 9);
histograms.ExpectBucketCount(SiteEngagementMetrics::kEngagementTypeHistogram,
SiteEngagementMetrics::ENGAGEMENT_NAVIGATION, 4);
histograms.ExpectBucketCount(SiteEngagementMetrics::kEngagementTypeHistogram,
SiteEngagementMetrics::ENGAGEMENT_KEYPRESS, 1);
histograms.ExpectBucketCount(SiteEngagementMetrics::kEngagementTypeHistogram,
- SiteEngagementMetrics::ENGAGEMENT_MOUSE, 2);
+ SiteEngagementMetrics::ENGAGEMENT_MOUSE, 1);
+ histograms.ExpectBucketCount(SiteEngagementMetrics::kEngagementTypeHistogram,
+ SiteEngagementMetrics::ENGAGEMENT_TOUCH_GESTURE,
+ 1);
+ histograms.ExpectBucketCount(SiteEngagementMetrics::kEngagementTypeHistogram,
+ SiteEngagementMetrics::ENGAGEMENT_MEDIA_VISIBLE,
+ 1);
+ histograms.ExpectBucketCount(SiteEngagementMetrics::kEngagementTypeHistogram,
+ SiteEngagementMetrics::ENGAGEMENT_MEDIA_HIDDEN,
+ 1);
service->HandleNavigation(url1, ui::PAGE_TRANSITION_GENERATED);
service->HandleNavigation(url1, ui::PAGE_TRANSITION_TYPED);
- service->HandleUserInput(url2, SiteEngagementMetrics::ENGAGEMENT_KEYPRESS);
+ service->HandleUserInput(url2, SiteEngagementMetrics::ENGAGEMENT_WHEEL);
service->HandleUserInput(url1, SiteEngagementMetrics::ENGAGEMENT_KEYPRESS);
service->HandleUserInput(url3, SiteEngagementMetrics::ENGAGEMENT_MOUSE);
histograms.ExpectTotalCount(SiteEngagementMetrics::kEngagementTypeHistogram,
- 12);
+ 14);
histograms.ExpectBucketCount(SiteEngagementMetrics::kEngagementTypeHistogram,
SiteEngagementMetrics::ENGAGEMENT_NAVIGATION, 6);
histograms.ExpectBucketCount(SiteEngagementMetrics::kEngagementTypeHistogram,
- SiteEngagementMetrics::ENGAGEMENT_KEYPRESS, 3);
+ SiteEngagementMetrics::ENGAGEMENT_KEYPRESS, 2);
histograms.ExpectBucketCount(SiteEngagementMetrics::kEngagementTypeHistogram,
- SiteEngagementMetrics::ENGAGEMENT_MOUSE, 3);
+ SiteEngagementMetrics::ENGAGEMENT_MOUSE, 2);
+ histograms.ExpectBucketCount(SiteEngagementMetrics::kEngagementTypeHistogram,
+ SiteEngagementMetrics::ENGAGEMENT_TOUCH_GESTURE,
+ 1);
+ histograms.ExpectBucketCount(SiteEngagementMetrics::kEngagementTypeHistogram,
+ SiteEngagementMetrics::ENGAGEMENT_WHEEL, 1);
// Advance an origin to the max for a day and advance the clock an hour before
// the last increment before max. Expect the histogram to be updated.
@@ -664,14 +694,10 @@ TEST_F(SiteEngagementServiceTest, CheckHistograms) {
histograms.ExpectUniqueSample(
SiteEngagementMetrics::kPercentOriginsWithMaxEngagementHistogram, 0, 3);
histograms.ExpectTotalCount(SiteEngagementMetrics::kEngagementTypeHistogram,
- 19);
+ 21);
histograms.ExpectBucketCount(SiteEngagementMetrics::kEngagementTypeHistogram,
SiteEngagementMetrics::ENGAGEMENT_NAVIGATION,
13);
- histograms.ExpectBucketCount(SiteEngagementMetrics::kEngagementTypeHistogram,
- SiteEngagementMetrics::ENGAGEMENT_KEYPRESS, 3);
- histograms.ExpectBucketCount(SiteEngagementMetrics::kEngagementTypeHistogram,
- SiteEngagementMetrics::ENGAGEMENT_MOUSE, 3);
}
// Expect that sites that have reached zero engagement are cleaned up.
« no previous file with comments | « chrome/browser/engagement/site_engagement_service.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698