OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 ASSERT_TRUE(window->AppendTab(net::FilePathToFileURL(page2_path))); | 55 ASSERT_TRUE(window->AppendTab(net::FilePathToFileURL(page2_path))); |
56 } | 56 } |
57 | 57 |
58 // Get a PrefService whose contents correspond to the Local State file | 58 // Get a PrefService whose contents correspond to the Local State file |
59 // that was saved by the app as it closed. The caller takes ownership of the | 59 // that was saved by the app as it closed. The caller takes ownership of the |
60 // returned PrefService object. | 60 // returned PrefService object. |
61 PrefService* GetLocalState() { | 61 PrefService* GetLocalState() { |
62 FilePath path = user_data_dir().Append(chrome::kLocalStateFilename); | 62 FilePath path = user_data_dir().Append(chrome::kLocalStateFilename); |
63 return PrefServiceMockBuilder().WithUserFilePrefs(path).Create(); | 63 return PrefServiceMockBuilder().WithUserFilePrefs(path).Create(); |
64 } | 64 } |
65 | |
66 private: | |
67 NotificationService notification_service_; | |
68 }; | 65 }; |
69 | 66 |
70 TEST_F(MetricsServiceTest, CloseRenderersNormally) { | 67 TEST_F(MetricsServiceTest, CloseRenderersNormally) { |
71 OpenTabs(); | 68 OpenTabs(); |
72 QuitBrowser(); | 69 QuitBrowser(); |
73 | 70 |
74 scoped_ptr<PrefService> local_state(GetLocalState()); | 71 scoped_ptr<PrefService> local_state(GetLocalState()); |
75 local_state->RegisterBooleanPref(prefs::kStabilityExitedCleanly, true); | 72 local_state->RegisterBooleanPref(prefs::kStabilityExitedCleanly, true); |
76 local_state->RegisterIntegerPref(prefs::kStabilityLaunchCount, 0); | 73 local_state->RegisterIntegerPref(prefs::kStabilityLaunchCount, 0); |
77 local_state->RegisterIntegerPref(prefs::kStabilityPageLoadCount, 0); | 74 local_state->RegisterIntegerPref(prefs::kStabilityPageLoadCount, 0); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 EXPECT_TRUE(local_state->GetBoolean(prefs::kStabilityExitedCleanly)); | 120 EXPECT_TRUE(local_state->GetBoolean(prefs::kStabilityExitedCleanly)); |
124 EXPECT_EQ(1, local_state->GetInteger(prefs::kStabilityLaunchCount)); | 121 EXPECT_EQ(1, local_state->GetInteger(prefs::kStabilityLaunchCount)); |
125 #if defined(TOUCH_UI) | 122 #if defined(TOUCH_UI) |
126 // The keyboard page loads for touchui. | 123 // The keyboard page loads for touchui. |
127 EXPECT_EQ(5, local_state->GetInteger(prefs::kStabilityPageLoadCount)); | 124 EXPECT_EQ(5, local_state->GetInteger(prefs::kStabilityPageLoadCount)); |
128 #else | 125 #else |
129 EXPECT_EQ(4, local_state->GetInteger(prefs::kStabilityPageLoadCount)); | 126 EXPECT_EQ(4, local_state->GetInteger(prefs::kStabilityPageLoadCount)); |
130 #endif | 127 #endif |
131 EXPECT_EQ(1, local_state->GetInteger(prefs::kStabilityRendererCrashCount)); | 128 EXPECT_EQ(1, local_state->GetInteger(prefs::kStabilityRendererCrashCount)); |
132 } | 129 } |
OLD | NEW |