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

Unified Diff: chrome/browser/safe_browsing/chrome_password_protection_service_unittest.cc

Issue 2869253002: Add UMA metrics to phishguard pings (Closed)
Patch Set: resolve comments on histograms.xml Created 3 years, 7 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
Index: chrome/browser/safe_browsing/chrome_password_protection_service_unittest.cc
diff --git a/chrome/browser/safe_browsing/chrome_password_protection_service_unittest.cc b/chrome/browser/safe_browsing/chrome_password_protection_service_unittest.cc
index 4152ac08f64bd5d858dc5bc2f2dd3315359dda23..e721bf4b8a37612e538ca55a516e596b47c02dfb 100644
--- a/chrome/browser/safe_browsing/chrome_password_protection_service_unittest.cc
+++ b/chrome/browser/safe_browsing/chrome_password_protection_service_unittest.cc
@@ -74,8 +74,12 @@ class ChromePasswordProtectionServiceTest : public testing::Test {
TEST_F(ChromePasswordProtectionServiceTest,
VerifyFinchControlForLowReputationPingSBEROnlyNoIncognito) {
MockChromePasswordProtectionService service;
+ PasswordProtectionService::RequestOutcome reason;
+
// By default kPasswordFieldOnFocusPinging feature is disabled.
- EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
+ EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging, &reason));
+ EXPECT_EQ(PasswordProtectionService::DISABLED_DUE_TO_FEATURE_DISABLED,
+ reason);
// Enables kPasswordFieldOnFocusPinging feature.
scoped_feature_list_.InitAndEnableFeature(kPasswordFieldOnFocusPinging);
@@ -93,29 +97,42 @@ TEST_F(ChromePasswordProtectionServiceTest,
CreateParameters(false, false, true, false);
SetFeatureParams(kPasswordFieldOnFocusPinging, "SBEROnlyNoIncognito",
sber_and_no_incognito);
+
service.ConfigService(false /*incognito*/, false /*SBER*/, false /*sync*/);
- EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
+ EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging, &reason));
+ EXPECT_EQ(PasswordProtectionService::DISABLED_DUE_TO_USER_POPULATION, reason);
+
service.ConfigService(false /*incognito*/, false /*SBER*/, true /*sync*/);
- EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
+ EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging, &reason));
+ EXPECT_EQ(PasswordProtectionService::DISABLED_DUE_TO_USER_POPULATION, reason);
+
service.ConfigService(false /*incognito*/, true /*SBER*/, false /*sync*/);
- EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
+ EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging, &reason));
+
service.ConfigService(false /*incognito*/, true /*SBER*/, true /*sync*/);
- EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
+ EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging, &reason));
+
service.ConfigService(true /*incognito*/, false /*SBER*/, false /*sync*/);
- EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
+ EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging, &reason));
+ EXPECT_EQ(PasswordProtectionService::DISABLED_DUE_TO_INCOGNITO, reason);
+
service.ConfigService(true /*incognito*/, false /*SBER*/, true /*sync*/);
- EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
+ EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging, &reason));
+ EXPECT_EQ(PasswordProtectionService::DISABLED_DUE_TO_INCOGNITO, reason);
+
service.ConfigService(true /*incognito*/, true /*SBER*/, false /*sync*/);
- EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
+ EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging, &reason));
+ EXPECT_EQ(PasswordProtectionService::DISABLED_DUE_TO_INCOGNITO, reason);
+
service.ConfigService(true /*incognito*/, true /*SBER*/, true /*sync*/);
- EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
+ EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging, &reason));
+ EXPECT_EQ(PasswordProtectionService::DISABLED_DUE_TO_INCOGNITO, reason);
}
TEST_F(ChromePasswordProtectionServiceTest,
VerifyFinchControlForLowReputationPingSBERAndHistorySyncNoIncognito) {
MockChromePasswordProtectionService service;
- // By default kPasswordFieldOnFocusPinging feature is disabled.
- EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
+ PasswordProtectionService::RequestOutcome reason;
// Enables kPasswordFieldOnFocusPinging feature.
scoped_feature_list_.InitAndEnableFeature(kPasswordFieldOnFocusPinging);
@@ -134,28 +151,39 @@ TEST_F(ChromePasswordProtectionServiceTest,
SetFeatureParams(kPasswordFieldOnFocusPinging,
"SBERAndHistorySyncNoIncognito", sber_and_sync_no_incognito);
service.ConfigService(false /*incognito*/, false /*SBER*/, false /*sync*/);
- EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
+ EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging, &reason));
+ EXPECT_EQ(PasswordProtectionService::DISABLED_DUE_TO_USER_POPULATION, reason);
+
service.ConfigService(false /*incognito*/, false /*SBER*/, true /*sync*/);
- EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
+ EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging, &reason));
+
service.ConfigService(false /*incognito*/, true /*SBER*/, false /*sync*/);
- EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
+ EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging, &reason));
+
service.ConfigService(false /*incognito*/, true /*SBER*/, true /*sync*/);
- EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
+ EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging, &reason));
+
service.ConfigService(true /*incognito*/, false /*SBER*/, false /*sync*/);
- EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
+ EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging, &reason));
+ EXPECT_EQ(PasswordProtectionService::DISABLED_DUE_TO_INCOGNITO, reason);
+
service.ConfigService(true /*incognito*/, false /*SBER*/, true /*sync*/);
- EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
+ EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging, &reason));
+ EXPECT_EQ(PasswordProtectionService::DISABLED_DUE_TO_INCOGNITO, reason);
+
service.ConfigService(true /*incognito*/, true /*SBER*/, false /*sync*/);
- EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
+ EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging, &reason));
+ EXPECT_EQ(PasswordProtectionService::DISABLED_DUE_TO_INCOGNITO, reason);
+
service.ConfigService(true /*incognito*/, true /*SBER*/, true /*sync*/);
- EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
+ EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging, &reason));
+ EXPECT_EQ(PasswordProtectionService::DISABLED_DUE_TO_INCOGNITO, reason);
}
TEST_F(ChromePasswordProtectionServiceTest,
VerifyFinchControlForLowReputationPingAllButNoIncognito) {
MockChromePasswordProtectionService service;
- // By default kPasswordFieldOnFocusPinging feature is disabled.
- EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
+ PasswordProtectionService::RequestOutcome reason;
// Enables kPasswordFieldOnFocusPinging feature.
scoped_feature_list_.InitAndEnableFeature(kPasswordFieldOnFocusPinging);
@@ -172,28 +200,38 @@ TEST_F(ChromePasswordProtectionServiceTest,
SetFeatureParams(kPasswordFieldOnFocusPinging, "AllButNoIncognito",
all_users);
service.ConfigService(false /*incognito*/, false /*SBER*/, false /*sync*/);
- EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
+ EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging, &reason));
+
service.ConfigService(false /*incognito*/, false /*SBER*/, true /*sync*/);
- EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
+ EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging, &reason));
+
service.ConfigService(false /*incognito*/, true /*SBER*/, false /*sync*/);
- EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
+ EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging, &reason));
+
service.ConfigService(false /*incognito*/, true /*SBER*/, true /*sync*/);
- EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
+ EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging, &reason));
+
service.ConfigService(true /*incognito*/, false /*SBER*/, false /*sync*/);
- EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
+ EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging, &reason));
+ EXPECT_EQ(PasswordProtectionService::DISABLED_DUE_TO_INCOGNITO, reason);
+
service.ConfigService(true /*incognito*/, false /*SBER*/, true /*sync*/);
- EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
+ EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging, &reason));
+ EXPECT_EQ(PasswordProtectionService::DISABLED_DUE_TO_INCOGNITO, reason);
+
service.ConfigService(true /*incognito*/, true /*SBER*/, false /*sync*/);
- EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
+ EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging, &reason));
+ EXPECT_EQ(PasswordProtectionService::DISABLED_DUE_TO_INCOGNITO, reason);
+
service.ConfigService(true /*incognito*/, true /*SBER*/, true /*sync*/);
- EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
+ EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging, &reason));
+ EXPECT_EQ(PasswordProtectionService::DISABLED_DUE_TO_INCOGNITO, reason);
}
TEST_F(ChromePasswordProtectionServiceTest,
VerifyFinchControlForLowReputationPingAll) {
MockChromePasswordProtectionService service;
- // By default kPasswordFieldOnFocusPinging feature is disabled.
- EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
+ PasswordProtectionService::RequestOutcome reason;
// Enables kPasswordFieldOnFocusPinging feature.
scoped_feature_list_.InitAndEnableFeature(kPasswordFieldOnFocusPinging);
@@ -209,21 +247,21 @@ TEST_F(ChromePasswordProtectionServiceTest,
Parameters all_users = CreateParameters(true, true, true, true);
SetFeatureParams(kPasswordFieldOnFocusPinging, "All", all_users);
service.ConfigService(false /*incognito*/, false /*SBER*/, false /*sync*/);
- EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
+ EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging, &reason));
service.ConfigService(false /*incognito*/, false /*SBER*/, true /*sync*/);
- EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
+ EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging, &reason));
service.ConfigService(false /*incognito*/, true /*SBER*/, false /*sync*/);
- EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
+ EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging, &reason));
service.ConfigService(false /*incognito*/, true /*SBER*/, true /*sync*/);
- EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
+ EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging, &reason));
service.ConfigService(true /*incognito*/, false /*SBER*/, false /*sync*/);
- EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
+ EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging, &reason));
service.ConfigService(true /*incognito*/, false /*SBER*/, true /*sync*/);
- EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
+ EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging, &reason));
service.ConfigService(true /*incognito*/, true /*SBER*/, false /*sync*/);
- EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
+ EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging, &reason));
service.ConfigService(true /*incognito*/, true /*SBER*/, true /*sync*/);
- EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
+ EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging, &reason));
}
} // namespace safe_browsing

Powered by Google App Engine
This is Rietveld 408576698