OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // Tests the MetricsService stat recording to make sure that the numbers are | 5 // Tests the MetricsService stat recording to make sure that the numbers are |
6 // what we expect. | 6 // what we expect. |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 ASSERT_TRUE(window->AppendTab(net::FilePathToFileURL(page2_path))); | 47 ASSERT_TRUE(window->AppendTab(net::FilePathToFileURL(page2_path))); |
48 } | 48 } |
49 | 49 |
50 // Get a PrefService whose contents correspond to the Local State file | 50 // Get a PrefService whose contents correspond to the Local State file |
51 // that was saved by the app as it closed. The caller takes ownership of the | 51 // that was saved by the app as it closed. The caller takes ownership of the |
52 // returned PrefService object. | 52 // returned PrefService object. |
53 PrefService* GetLocalState() { | 53 PrefService* GetLocalState() { |
54 FilePath local_state_path = user_data_dir() | 54 FilePath local_state_path = user_data_dir() |
55 .Append(chrome::kLocalStateFilename); | 55 .Append(chrome::kLocalStateFilename); |
56 | 56 |
57 return new PrefService(new PrefValueStore( | 57 return PrefService::CreateUserPrefService(local_state_path); |
58 NULL, /* no managed preferences */ | |
59 new JsonPrefStore( /* local user preferences */ | |
60 local_state_path, | |
61 ChromeThread::GetMessageLoopProxyForThread(ChromeThread::FILE)), | |
62 NULL /* no recommended preferences */)); | |
63 } | 58 } |
64 }; | 59 }; |
65 | 60 |
66 TEST_F(MetricsServiceTest, CloseRenderersNormally) { | 61 TEST_F(MetricsServiceTest, CloseRenderersNormally) { |
67 OpenTabs(); | 62 OpenTabs(); |
68 QuitBrowser(); | 63 QuitBrowser(); |
69 | 64 |
70 scoped_ptr<PrefService> local_state(GetLocalState()); | 65 scoped_ptr<PrefService> local_state(GetLocalState()); |
71 local_state->RegisterBooleanPref(prefs::kStabilityExitedCleanly, true); | 66 local_state->RegisterBooleanPref(prefs::kStabilityExitedCleanly, true); |
72 local_state->RegisterIntegerPref(prefs::kStabilityLaunchCount, 0); | 67 local_state->RegisterIntegerPref(prefs::kStabilityLaunchCount, 0); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 scoped_ptr<PrefService> local_state(GetLocalState()); | 111 scoped_ptr<PrefService> local_state(GetLocalState()); |
117 local_state->RegisterBooleanPref(prefs::kStabilityExitedCleanly, true); | 112 local_state->RegisterBooleanPref(prefs::kStabilityExitedCleanly, true); |
118 local_state->RegisterIntegerPref(prefs::kStabilityLaunchCount, 0); | 113 local_state->RegisterIntegerPref(prefs::kStabilityLaunchCount, 0); |
119 local_state->RegisterIntegerPref(prefs::kStabilityPageLoadCount, 0); | 114 local_state->RegisterIntegerPref(prefs::kStabilityPageLoadCount, 0); |
120 local_state->RegisterIntegerPref(prefs::kStabilityRendererCrashCount, 0); | 115 local_state->RegisterIntegerPref(prefs::kStabilityRendererCrashCount, 0); |
121 EXPECT_TRUE(local_state->GetBoolean(prefs::kStabilityExitedCleanly)); | 116 EXPECT_TRUE(local_state->GetBoolean(prefs::kStabilityExitedCleanly)); |
122 EXPECT_EQ(1, local_state->GetInteger(prefs::kStabilityLaunchCount)); | 117 EXPECT_EQ(1, local_state->GetInteger(prefs::kStabilityLaunchCount)); |
123 EXPECT_EQ(4, local_state->GetInteger(prefs::kStabilityPageLoadCount)); | 118 EXPECT_EQ(4, local_state->GetInteger(prefs::kStabilityPageLoadCount)); |
124 EXPECT_EQ(1, local_state->GetInteger(prefs::kStabilityRendererCrashCount)); | 119 EXPECT_EQ(1, local_state->GetInteger(prefs::kStabilityRendererCrashCount)); |
125 } | 120 } |
OLD | NEW |