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

Side by Side Diff: chrome/browser/metrics/cloned_install_detector_unittest.cc

Issue 256143006: Refactor MetricsStateManager class out of MetricsService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/chrome_browser_main.cc ('k') | chrome/browser/metrics/metrics_service.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/cloned_install_detector.h" 5 #include "chrome/browser/metrics/cloned_install_detector.h"
6 6
7 #include "base/prefs/testing_pref_service.h" 7 #include "base/prefs/testing_pref_service.h"
8 #include "chrome/browser/metrics/machine_id_provider.h" 8 #include "chrome/browser/metrics/machine_id_provider.h"
9 #include "chrome/browser/metrics/metrics_service.h" 9 #include "chrome/browser/metrics/metrics_state_manager.h"
10 #include "chrome/common/pref_names.h" 10 #include "chrome/common/pref_names.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 12
13 namespace metrics { 13 namespace metrics {
14 14
15 namespace { 15 namespace {
16 16
17 const std::string kTestRawId = "test"; 17 const std::string kTestRawId = "test";
18 // Hashed machine id for |kTestRawId|. 18 // Hashed machine id for |kTestRawId|.
19 const int kTestHashedId = 2216819; 19 const int kTestHashedId = 2216819;
(...skipping 10 matching lines...) Expand all
30 scoped_ptr<ClonedInstallDetector> detector( 30 scoped_ptr<ClonedInstallDetector> detector(
31 new ClonedInstallDetector(MachineIdProvider::CreateInstance())); 31 new ClonedInstallDetector(MachineIdProvider::CreateInstance()));
32 32
33 detector->SaveMachineId(&prefs, kTestRawId); 33 detector->SaveMachineId(&prefs, kTestRawId);
34 34
35 EXPECT_EQ(kTestHashedId, prefs.GetInteger(prefs::kMetricsMachineId)); 35 EXPECT_EQ(kTestHashedId, prefs.GetInteger(prefs::kMetricsMachineId));
36 } 36 }
37 37
38 TEST(ClonedInstallDetectorTest, DetectClone) { 38 TEST(ClonedInstallDetectorTest, DetectClone) {
39 TestingPrefServiceSimple prefs; 39 TestingPrefServiceSimple prefs;
40 ClonedInstallDetector::RegisterPrefs(prefs.registry()); 40 MetricsStateManager::RegisterPrefs(prefs.registry());
41 MetricsService::RegisterPrefs(prefs.registry());
42 41
43 // Save a machine id that will cause a clone to be detected. 42 // Save a machine id that will cause a clone to be detected.
44 prefs.SetInteger(prefs::kMetricsMachineId, kTestHashedId + 1); 43 prefs.SetInteger(prefs::kMetricsMachineId, kTestHashedId + 1);
45 44
46 scoped_ptr<ClonedInstallDetector> detector( 45 scoped_ptr<ClonedInstallDetector> detector(
47 new ClonedInstallDetector(MachineIdProvider::CreateInstance())); 46 new ClonedInstallDetector(MachineIdProvider::CreateInstance()));
48 47
49 detector->SaveMachineId(&prefs, kTestRawId); 48 detector->SaveMachineId(&prefs, kTestRawId);
50 49
51 EXPECT_TRUE(prefs.GetBoolean(prefs::kMetricsResetIds)); 50 EXPECT_TRUE(prefs.GetBoolean(prefs::kMetricsResetIds));
52 } 51 }
53 52
54 } // namespace metrics 53 } // namespace metrics
OLDNEW
« no previous file with comments | « chrome/browser/chrome_browser_main.cc ('k') | chrome/browser/metrics/metrics_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698