OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/metrics/metrics_service.h" | 5 #include "chrome/browser/metrics/metrics_service.h" |
6 | 6 |
7 #include <ctype.h> | 7 #include <ctype.h> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 GetLocalState()->SetBoolean(crash_pref, true); | 367 GetLocalState()->SetBoolean(crash_pref, true); |
368 EXPECT_TRUE(MetricsServiceHelper::IsCrashReportingEnabled()); | 368 EXPECT_TRUE(MetricsServiceHelper::IsCrashReportingEnabled()); |
369 GetLocalState()->ClearPref(crash_pref); | 369 GetLocalState()->ClearPref(crash_pref); |
370 EXPECT_FALSE(MetricsServiceHelper::IsCrashReportingEnabled()); | 370 EXPECT_FALSE(MetricsServiceHelper::IsCrashReportingEnabled()); |
371 #endif // !defined(OS_CHROMEOS) | 371 #endif // !defined(OS_CHROMEOS) |
372 #else // defined(GOOGLE_CHROME_BUILD) | 372 #else // defined(GOOGLE_CHROME_BUILD) |
373 // Chromium branded browsers never have crash reporting enabled. | 373 // Chromium branded browsers never have crash reporting enabled. |
374 EXPECT_FALSE(MetricsServiceHelper::IsCrashReportingEnabled()); | 374 EXPECT_FALSE(MetricsServiceHelper::IsCrashReportingEnabled()); |
375 #endif // defined(GOOGLE_CHROME_BUILD) | 375 #endif // defined(GOOGLE_CHROME_BUILD) |
376 } | 376 } |
| 377 |
| 378 TEST_F(MetricsServiceTest, ResetMetricsIDs) { |
| 379 // Ensuere that the low entropy source and client id have been generated. |
| 380 { |
| 381 MetricsService service; |
| 382 service.ForceClientIdCreation(); |
| 383 service.GetLowEntropySource(); |
| 384 } |
| 385 |
| 386 std::string old_client_id = |
| 387 GetLocalState()->GetString(prefs::kMetricsClientID); |
| 388 int old_low_entropy_value = |
| 389 GetLocalState()->GetInteger(prefs::kMetricsLowEntropySource); |
| 390 |
| 391 // Set the reset pref to cause the IDs to be reset. |
| 392 GetLocalState()->SetBoolean(prefs::kMetricsResetIds, true); |
| 393 |
| 394 // Cause the actual reset to happen. |
| 395 { |
| 396 MetricsService service; |
| 397 service.ForceClientIdCreation(); |
| 398 EXPECT_TRUE(service.metrics_ids_reset_check_performed_); |
| 399 EXPECT_NE(old_client_id, service.client_id_); |
| 400 |
| 401 service.GetLowEntropySource(); |
| 402 EXPECT_NE(old_low_entropy_value, service.low_entropy_source_); |
| 403 |
| 404 EXPECT_FALSE(GetLocalState()->GetBoolean(prefs::kMetricsResetIds)); |
| 405 } |
| 406 |
| 407 std::string new_client_id = |
| 408 GetLocalState()->GetString(prefs::kMetricsClientID); |
| 409 int new_low_entropy_value = |
| 410 GetLocalState()->GetInteger(prefs::kMetricsLowEntropySource); |
| 411 |
| 412 EXPECT_NE(old_client_id, new_client_id); |
| 413 EXPECT_NE(old_low_entropy_value, new_low_entropy_value); |
| 414 } |
OLD | NEW |