OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 ASSERT_TRUE(window->AppendTab(net::FilePathToFileURL(page2_path))); | 45 ASSERT_TRUE(window->AppendTab(net::FilePathToFileURL(page2_path))); |
46 } | 46 } |
47 | 47 |
48 // Get a PrefService whose contents correspond to the Local State file | 48 // Get a PrefService whose contents correspond to the Local State file |
49 // that was saved by the app as it closed. The caller takes ownership of the | 49 // that was saved by the app as it closed. The caller takes ownership of the |
50 // returned PrefService object. | 50 // returned PrefService object. |
51 PrefService* GetLocalState() { | 51 PrefService* GetLocalState() { |
52 FilePath local_state_path = user_data_dir() | 52 FilePath local_state_path = user_data_dir() |
53 .Append(chrome::kLocalStateFilename); | 53 .Append(chrome::kLocalStateFilename); |
54 | 54 |
55 PrefService* local_state(new PrefService(local_state_path, NULL)); | 55 return new PrefService(local_state_path); |
56 return local_state; | |
57 } | 56 } |
58 }; | 57 }; |
59 | 58 |
60 TEST_F(MetricsServiceTest, CloseRenderersNormally) { | 59 TEST_F(MetricsServiceTest, CloseRenderersNormally) { |
61 OpenTabs(); | 60 OpenTabs(); |
62 QuitBrowser(); | 61 QuitBrowser(); |
63 | 62 |
64 scoped_ptr<PrefService> local_state(GetLocalState()); | 63 scoped_ptr<PrefService> local_state(GetLocalState()); |
65 local_state->RegisterBooleanPref(prefs::kStabilityExitedCleanly, true); | 64 local_state->RegisterBooleanPref(prefs::kStabilityExitedCleanly, true); |
66 local_state->RegisterIntegerPref(prefs::kStabilityLaunchCount, 0); | 65 local_state->RegisterIntegerPref(prefs::kStabilityLaunchCount, 0); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 scoped_ptr<PrefService> local_state(GetLocalState()); | 104 scoped_ptr<PrefService> local_state(GetLocalState()); |
106 local_state->RegisterBooleanPref(prefs::kStabilityExitedCleanly, true); | 105 local_state->RegisterBooleanPref(prefs::kStabilityExitedCleanly, true); |
107 local_state->RegisterIntegerPref(prefs::kStabilityLaunchCount, 0); | 106 local_state->RegisterIntegerPref(prefs::kStabilityLaunchCount, 0); |
108 local_state->RegisterIntegerPref(prefs::kStabilityPageLoadCount, 0); | 107 local_state->RegisterIntegerPref(prefs::kStabilityPageLoadCount, 0); |
109 local_state->RegisterIntegerPref(prefs::kStabilityRendererCrashCount, 0); | 108 local_state->RegisterIntegerPref(prefs::kStabilityRendererCrashCount, 0); |
110 EXPECT_TRUE(local_state->GetBoolean(prefs::kStabilityExitedCleanly)); | 109 EXPECT_TRUE(local_state->GetBoolean(prefs::kStabilityExitedCleanly)); |
111 EXPECT_EQ(1, local_state->GetInteger(prefs::kStabilityLaunchCount)); | 110 EXPECT_EQ(1, local_state->GetInteger(prefs::kStabilityLaunchCount)); |
112 EXPECT_EQ(4, local_state->GetInteger(prefs::kStabilityPageLoadCount)); | 111 EXPECT_EQ(4, local_state->GetInteger(prefs::kStabilityPageLoadCount)); |
113 EXPECT_EQ(1, local_state->GetInteger(prefs::kStabilityRendererCrashCount)); | 112 EXPECT_EQ(1, local_state->GetInteger(prefs::kStabilityRendererCrashCount)); |
114 } | 113 } |
OLD | NEW |