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

Unified Diff: chrome/installer/util/google_update_settings_unittest.cc

Issue 2222903004: Clear client id prefs when opting out of UMA. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove early return in ForceClientIdCreation(). Created 4 years, 4 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/installer/util/google_update_settings_unittest.cc
diff --git a/chrome/installer/util/google_update_settings_unittest.cc b/chrome/installer/util/google_update_settings_unittest.cc
index 6f51af351dab9771c138a38c73bc8f6e64877e21..3654812794c431b2ad6d59912ca81c61e7ca0424 100644
--- a/chrome/installer/util/google_update_settings_unittest.cc
+++ b/chrome/installer/util/google_update_settings_unittest.cc
@@ -1271,13 +1271,12 @@ void CollectStatsConsent::TearDownTestCase() {
// Install the registry override and apply the settings to the registry.
void CollectStatsConsent::SetUp() {
+ // Override both HKLM and HKCU as tests may touch either/both.
+ override_manager_.OverrideRegistry(HKEY_LOCAL_MACHINE);
+ override_manager_.OverrideRegistry(HKEY_CURRENT_USER);
+
const StatsState& stats_state = GetParam();
const HKEY root_key = stats_state.root_key();
- base::string16 reg_temp_name(
- stats_state.system_level() ? L"HKLM_" : L"HKCU_");
- reg_temp_name += L"CollectStatsConsent";
- override_manager_.OverrideRegistry(root_key);
-
if (stats_state.multi_install()) {
MakeChromeMultiInstall(root_key);
ApplySetting(stats_state.state_value(), root_key, *binaries_state_key_);
@@ -1333,9 +1332,20 @@ TEST_P(CollectStatsConsent, GetCollectStatsConsentAtLevel) {
// Test that stats consent can be flipped to the opposite setting, that the new
// setting takes affect, and that the correct registry location is modified.
TEST_P(CollectStatsConsent, SetCollectStatsConsentAtLevel) {
+ // When testing revoking consent, verify that backup client info is cleared.
+ // To do so, first add some backup client info.
+ if (GetParam().is_consent_granted()) {
+ metrics::ClientInfo client_info;
+ client_info.client_id = "01234567-89ab-cdef-fedc-ba9876543210";
+ client_info.installation_date = 123;
+ client_info.reporting_enabled_date = 345;
+ GoogleUpdateSettings::StoreMetricsClientInfo(client_info);
+ }
+
EXPECT_TRUE(GoogleUpdateSettings::SetCollectStatsConsentAtLevel(
GetParam().system_level(),
!GetParam().is_consent_granted()));
+
const base::string16* const reg_keys[] = {
chrome_state_key_,
chrome_state_medium_key_,
@@ -1359,6 +1369,8 @@ TEST_P(CollectStatsConsent, SetCollectStatsConsentAtLevel) {
EXPECT_TRUE(GoogleUpdateSettings::GetCollectStatsConsentAtLevel(
GetParam().system_level()));
EXPECT_EQ(1UL, value);
+ // Verify that backup client info has been cleared.
+ EXPECT_FALSE(GoogleUpdateSettings::LoadMetricsClientInfo());
}
}

Powered by Google App Engine
This is Rietveld 408576698