Index: chrome/browser/geolocation/geolocation_permission_context_unittest.cc |
diff --git a/chrome/browser/geolocation/geolocation_permission_context_unittest.cc b/chrome/browser/geolocation/geolocation_permission_context_unittest.cc |
index b543388b8471cb2c5890ec5a6e257cec54083e1e..a0bc90210efdbb7f1325a3da9e019bb27a3ee512 100644 |
--- a/chrome/browser/geolocation/geolocation_permission_context_unittest.cc |
+++ b/chrome/browser/geolocation/geolocation_permission_context_unittest.cc |
@@ -19,6 +19,7 @@ |
#include "base/memory/ptr_util.h" |
#include "base/strings/utf_string_conversions.h" |
#include "base/synchronization/waitable_event.h" |
+#include "base/test/histogram_tester.h" |
#include "base/test/scoped_feature_list.h" |
#include "base/test/simple_test_clock.h" |
#include "base/time/clock.h" |
@@ -620,6 +621,7 @@ TEST_F(GeolocationPermissionContextTests, SystemLocationOnNoLSD) { |
} |
TEST_F(GeolocationPermissionContextTests, SystemLocationOffLSDAccept) { |
+ base::HistogramTester tester; |
base::test::ScopedFeatureList scoped_feature_list; |
scoped_feature_list.InitAndEnableFeature(features::kLsdPermissionPrompt); |
@@ -640,9 +642,18 @@ TEST_F(GeolocationPermissionContextTests, SystemLocationOffLSDAccept) { |
CheckTabContentsState(requesting_frame, CONTENT_SETTING_ALLOW); |
CheckPermissionMessageSent(0, true); |
EXPECT_TRUE(MockLocationSettings::HasShownLocationSettingsDialog()); |
+ |
+ tester.ExpectTotalCount( |
+ GeolocationPermissionContextAndroid::kGeolocationLSDShowNonDSEMetric, 1); |
+ tester.ExpectTotalCount( |
+ GeolocationPermissionContextAndroid::kGeolocationLSDAcceptNonDSEMetric, |
+ 1); |
+ tester.ExpectTotalCount( |
+ GeolocationPermissionContextAndroid::kGeolocationLSDDenyNonDSEMetric, 0); |
} |
TEST_F(GeolocationPermissionContextTests, SystemLocationOffLSDReject) { |
+ base::HistogramTester tester; |
base::test::ScopedFeatureList scoped_feature_list; |
scoped_feature_list.InitAndEnableFeature(features::kLsdPermissionPrompt); |
@@ -663,9 +674,18 @@ TEST_F(GeolocationPermissionContextTests, SystemLocationOffLSDReject) { |
CheckTabContentsState(requesting_frame, CONTENT_SETTING_BLOCK); |
CheckPermissionMessageSent(0, false); |
EXPECT_TRUE(MockLocationSettings::HasShownLocationSettingsDialog()); |
+ |
+ tester.ExpectTotalCount( |
+ GeolocationPermissionContextAndroid::kGeolocationLSDShowNonDSEMetric, 1); |
+ tester.ExpectTotalCount( |
+ GeolocationPermissionContextAndroid::kGeolocationLSDAcceptNonDSEMetric, |
+ 0); |
+ tester.ExpectTotalCount( |
+ GeolocationPermissionContextAndroid::kGeolocationLSDDenyNonDSEMetric, 1); |
} |
TEST_F(GeolocationPermissionContextTests, LSDBackOffDifferentSites) { |
+ base::HistogramTester tester; |
base::test::ScopedFeatureList scoped_feature_list; |
scoped_feature_list.InitAndEnableFeature(features::kLsdPermissionPrompt); |
@@ -702,15 +722,38 @@ TEST_F(GeolocationPermissionContextTests, LSDBackOffDifferentSites) { |
// Now ask on the other non-DSE origin and check backoff prevented the prompt. |
EXPECT_FALSE(RequestPermissionIsLSDShown(requesting_frame_2)); |
+ // Test that the right histograms are updated. |
+ tester.ExpectTotalCount( |
+ GeolocationPermissionContextAndroid::kGeolocationLSDShowNonDSEMetric, 1); |
+ tester.ExpectTotalCount( |
+ GeolocationPermissionContextAndroid::kGeolocationLSDShowDSEMetric, 0); |
+ tester.ExpectTotalCount( |
+ GeolocationPermissionContextAndroid::kGeolocationLSDSuppressNonDSEMetric, |
+ 2); |
+ tester.ExpectTotalCount( |
+ GeolocationPermissionContextAndroid::kGeolocationLSDSuppressDSEMetric, 0); |
+ |
// Now request on the DSE and check that the LSD is shown, as the non-DSE |
// backoff should not apply. |
EXPECT_TRUE(RequestPermissionIsLSDShown(requesting_frame_dse)); |
// Now check that the DSE is in backoff. |
EXPECT_FALSE(RequestPermissionIsLSDShown(requesting_frame_dse)); |
+ |
+ // Test that the right histograms are updated. |
+ tester.ExpectTotalCount( |
+ GeolocationPermissionContextAndroid::kGeolocationLSDShowNonDSEMetric, 1); |
+ tester.ExpectTotalCount( |
+ GeolocationPermissionContextAndroid::kGeolocationLSDShowDSEMetric, 1); |
+ tester.ExpectTotalCount( |
+ GeolocationPermissionContextAndroid::kGeolocationLSDSuppressNonDSEMetric, |
+ 2); |
+ tester.ExpectTotalCount( |
+ GeolocationPermissionContextAndroid::kGeolocationLSDSuppressDSEMetric, 1); |
} |
TEST_F(GeolocationPermissionContextTests, LSDBackOffTiming) { |
+ base::HistogramTester tester; |
base::test::ScopedFeatureList scoped_feature_list; |
scoped_feature_list.InitAndEnableFeature(features::kLsdPermissionPrompt); |
@@ -732,6 +775,16 @@ TEST_F(GeolocationPermissionContextTests, LSDBackOffTiming) { |
AddDayOffsetForTesting(6); |
EXPECT_FALSE(RequestPermissionIsLSDShown(requesting_frame)); |
+ // Check histograms so far. |
+ tester.ExpectTotalCount( |
+ GeolocationPermissionContextAndroid::kGeolocationLSDShowNonDSEMetric, 1); |
+ tester.ExpectBucketCount( |
+ GeolocationPermissionContextAndroid::kGeolocationLSDShowNonDSEMetric, |
+ static_cast<base::HistogramBase::Sample>( |
+ GeolocationPermissionContextAndroid::LocationSettingsDialogBackOff:: |
+ kOneWeek), |
+ 1); |
+ |
// Check it is shown in one more days time, but then not straight after.. |
AddDayOffsetForTesting(1); |
EXPECT_TRUE(RequestPermissionIsLSDShown(requesting_frame)); |
@@ -741,6 +794,16 @@ TEST_F(GeolocationPermissionContextTests, LSDBackOffTiming) { |
AddDayOffsetForTesting(29); |
EXPECT_FALSE(RequestPermissionIsLSDShown(requesting_frame)); |
+ // Check histograms so far. |
+ tester.ExpectTotalCount( |
+ GeolocationPermissionContextAndroid::kGeolocationLSDShowNonDSEMetric, 2); |
+ tester.ExpectBucketCount( |
+ GeolocationPermissionContextAndroid::kGeolocationLSDShowNonDSEMetric, |
+ static_cast<base::HistogramBase::Sample>( |
+ GeolocationPermissionContextAndroid::LocationSettingsDialogBackOff:: |
+ kOneWeek), |
+ 1); |
+ |
// Check it is shown in one more days time, but then not straight after.. |
AddDayOffsetForTesting(1); |
EXPECT_TRUE(RequestPermissionIsLSDShown(requesting_frame)); |
@@ -763,6 +826,16 @@ TEST_F(GeolocationPermissionContextTests, LSDBackOffTiming) { |
AddDayOffsetForTesting(1); |
EXPECT_TRUE(RequestPermissionIsLSDShown(requesting_frame)); |
EXPECT_FALSE(RequestPermissionIsLSDShown(requesting_frame)); |
+ |
+ // Check histograms so far. |
+ tester.ExpectTotalCount( |
+ GeolocationPermissionContextAndroid::kGeolocationLSDShowNonDSEMetric, 5); |
+ tester.ExpectBucketCount( |
+ GeolocationPermissionContextAndroid::kGeolocationLSDShowNonDSEMetric, |
+ static_cast<base::HistogramBase::Sample>( |
+ GeolocationPermissionContextAndroid::LocationSettingsDialogBackOff:: |
+ kThreeMonths), |
+ 3); |
} |
TEST_F(GeolocationPermissionContextTests, LSDBackOffPermissionStatus) { |