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 // 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/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 observer.Wait(); | 86 observer.Wait(); |
87 | 87 |
88 // The MetricsService listens for the same notification, so the |observer| | 88 // The MetricsService listens for the same notification, so the |observer| |
89 // might finish waiting before the MetricsService has a chance to process the | 89 // might finish waiting before the MetricsService has a chance to process the |
90 // notification. To avoid racing here, we repeatedly run the message loop | 90 // notification. To avoid racing here, we repeatedly run the message loop |
91 // until the MetricsService catches up. This should happen "real soon now", | 91 // until the MetricsService catches up. This should happen "real soon now", |
92 // since the notification is posted to all observers essentially | 92 // since the notification is posted to all observers essentially |
93 // simultaneously... so busy waiting here shouldn't be too bad. | 93 // simultaneously... so busy waiting here shouldn't be too bad. |
94 const PrefService* prefs = g_browser_process->local_state(); | 94 const PrefService* prefs = g_browser_process->local_state(); |
95 while (!prefs->GetInteger(prefs::kStabilityRendererCrashCount)) { | 95 while (!prefs->GetInteger(prefs::kStabilityRendererCrashCount)) { |
96 ui_test_utils::RunAllPendingInMessageLoop(); | 96 content::RunAllPendingInMessageLoop(); |
97 } | 97 } |
98 | 98 |
99 // Verify that the expected stability metrics were recorded. | 99 // Verify that the expected stability metrics were recorded. |
100 EXPECT_EQ(1, prefs->GetInteger(prefs::kStabilityLaunchCount)); | 100 EXPECT_EQ(1, prefs->GetInteger(prefs::kStabilityLaunchCount)); |
101 EXPECT_EQ(4, prefs->GetInteger(prefs::kStabilityPageLoadCount)); | 101 EXPECT_EQ(4, prefs->GetInteger(prefs::kStabilityPageLoadCount)); |
102 EXPECT_EQ(1, prefs->GetInteger(prefs::kStabilityRendererCrashCount)); | 102 EXPECT_EQ(1, prefs->GetInteger(prefs::kStabilityRendererCrashCount)); |
103 // TODO(isherman): We should also verify that prefs::kStabilityExitedCleanly | 103 // TODO(isherman): We should also verify that prefs::kStabilityExitedCleanly |
104 // is set to true, but this preference isn't set until the browser | 104 // is set to true, but this preference isn't set until the browser |
105 // exits... it's not clear to me how to test that. | 105 // exits... it's not clear to me how to test that. |
106 } | 106 } |
OLD | NEW |