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

Unified Diff: chrome/browser/metrics/metrics_service_unittest.cc

Issue 213363004: Resetting metrics ids on clump detection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 9 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 | « chrome/browser/metrics/metrics_service.cc ('k') | chrome/common/pref_names.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/metrics/metrics_service_unittest.cc
diff --git a/chrome/browser/metrics/metrics_service_unittest.cc b/chrome/browser/metrics/metrics_service_unittest.cc
index 3ca255bf0b87af75e7f0db9092d7b085ff36f2d0..ae110db3e59f929f87df5e52b1c0b540d752c3ea 100644
--- a/chrome/browser/metrics/metrics_service_unittest.cc
+++ b/chrome/browser/metrics/metrics_service_unittest.cc
@@ -374,3 +374,42 @@ TEST_F(MetricsServiceTest, CrashReportingEnabled) {
EXPECT_FALSE(MetricsServiceHelper::IsCrashReportingEnabled());
#endif // defined(GOOGLE_CHROME_BUILD)
}
+
+// Check that setting the kMetricsResetIds pref to true causes the client id to
+// be reset. We do not check that the low entropy source is reset because we
+// cannot ensure that metrics service won't generate the same id again.
+TEST_F(MetricsServiceTest, ResetMetricsIDs) {
+ // Set an initial client id in prefs. It should not be possible for the
+ // metrics service to generate this id randomly.
+ const std::string kInitialClientId = "initial client id";
+ GetLocalState()->SetString(prefs::kMetricsClientID, kInitialClientId);
+
+ // Make sure the initial client id isn't reset by the metrics service.
+ {
+ MetricsService service;
+ service.ForceClientIdCreation();
+ EXPECT_TRUE(service.metrics_ids_reset_check_performed_);
+ EXPECT_EQ(kInitialClientId, service.client_id_);
+ }
+
+
+ // Set the reset pref to cause the IDs to be reset.
+ GetLocalState()->SetBoolean(prefs::kMetricsResetIds, true);
+
+ // Cause the actual reset to happen.
+ {
+ MetricsService service;
+ service.ForceClientIdCreation();
+ EXPECT_TRUE(service.metrics_ids_reset_check_performed_);
+ EXPECT_NE(kInitialClientId, service.client_id_);
+
+ service.GetLowEntropySource();
+
+ EXPECT_FALSE(GetLocalState()->GetBoolean(prefs::kMetricsResetIds));
+ }
+
+ std::string new_client_id =
+ GetLocalState()->GetString(prefs::kMetricsClientID);
+
+ EXPECT_NE(kInitialClientId, new_client_id);
+}
« no previous file with comments | « chrome/browser/metrics/metrics_service.cc ('k') | chrome/common/pref_names.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698