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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 // Verify that the expected stability metrics were recorded. | 62 // Verify that the expected stability metrics were recorded. |
63 const PrefService* prefs = g_browser_process->local_state(); | 63 const PrefService* prefs = g_browser_process->local_state(); |
64 EXPECT_EQ(1, prefs->GetInteger(prefs::kStabilityLaunchCount)); | 64 EXPECT_EQ(1, prefs->GetInteger(prefs::kStabilityLaunchCount)); |
65 EXPECT_EQ(3, prefs->GetInteger(prefs::kStabilityPageLoadCount)); | 65 EXPECT_EQ(3, prefs->GetInteger(prefs::kStabilityPageLoadCount)); |
66 EXPECT_EQ(0, prefs->GetInteger(prefs::kStabilityRendererCrashCount)); | 66 EXPECT_EQ(0, prefs->GetInteger(prefs::kStabilityRendererCrashCount)); |
67 // TODO(isherman): We should also verify that prefs::kStabilityExitedCleanly | 67 // TODO(isherman): We should also verify that prefs::kStabilityExitedCleanly |
68 // is set to true, but this preference isn't set until the browser | 68 // is set to true, but this preference isn't set until the browser |
69 // exits... it's not clear to me how to test that. | 69 // exits... it's not clear to me how to test that. |
70 } | 70 } |
71 | 71 |
72 IN_PROC_BROWSER_TEST_F(MetricsServiceTest, CrashRenderers) { | 72 // Flaky on Linux. See http://crbug.com/131094 |
| 73 #if defined(OS_LINUX) |
| 74 #define MAYBE_CrashRenderers DISABLED_CrashRenderers |
| 75 #else |
| 76 #define MAYBE_CrashRenderers CrashRenderers |
| 77 #endif |
| 78 IN_PROC_BROWSER_TEST_F(MetricsServiceTest, MAYBE_CrashRenderers) { |
73 OpenTabs(); | 79 OpenTabs(); |
74 | 80 |
75 // Kill the process for one of the tabs. | 81 // Kill the process for one of the tabs. |
76 ui_test_utils::WindowedNotificationObserver observer( | 82 ui_test_utils::WindowedNotificationObserver observer( |
77 content::NOTIFICATION_RENDERER_PROCESS_CLOSED, | 83 content::NOTIFICATION_RENDERER_PROCESS_CLOSED, |
78 content::NotificationService::AllSources()); | 84 content::NotificationService::AllSources()); |
79 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUICrashURL)); | 85 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUICrashURL)); |
80 observer.Wait(); | 86 observer.Wait(); |
81 | 87 |
82 // The MetricsService listens for the same notification, so the |observer| | 88 // The MetricsService listens for the same notification, so the |observer| |
83 // 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 |
84 // notification. To avoid racing here, we repeatedly run the message loop | 90 // notification. To avoid racing here, we repeatedly run the message loop |
85 // until the MetricsService catches up. This should happen "real soon now", | 91 // until the MetricsService catches up. This should happen "real soon now", |
86 // since the notification is posted to all observers essentially | 92 // since the notification is posted to all observers essentially |
87 // simultaneously... so busy waiting here shouldn't be too bad. | 93 // simultaneously... so busy waiting here shouldn't be too bad. |
88 const PrefService* prefs = g_browser_process->local_state(); | 94 const PrefService* prefs = g_browser_process->local_state(); |
89 while (!prefs->GetInteger(prefs::kStabilityRendererCrashCount)) { | 95 while (!prefs->GetInteger(prefs::kStabilityRendererCrashCount)) { |
90 ui_test_utils::RunAllPendingInMessageLoop(); | 96 ui_test_utils::RunAllPendingInMessageLoop(); |
91 } | 97 } |
92 | 98 |
93 // Verify that the expected stability metrics were recorded. | 99 // Verify that the expected stability metrics were recorded. |
94 EXPECT_EQ(1, prefs->GetInteger(prefs::kStabilityLaunchCount)); | 100 EXPECT_EQ(1, prefs->GetInteger(prefs::kStabilityLaunchCount)); |
95 EXPECT_EQ(4, prefs->GetInteger(prefs::kStabilityPageLoadCount)); | 101 EXPECT_EQ(4, prefs->GetInteger(prefs::kStabilityPageLoadCount)); |
96 EXPECT_EQ(1, prefs->GetInteger(prefs::kStabilityRendererCrashCount)); | 102 EXPECT_EQ(1, prefs->GetInteger(prefs::kStabilityRendererCrashCount)); |
97 // TODO(isherman): We should also verify that prefs::kStabilityExitedCleanly | 103 // TODO(isherman): We should also verify that prefs::kStabilityExitedCleanly |
98 // 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 |
99 // exits... it's not clear to me how to test that. | 105 // exits... it's not clear to me how to test that. |
100 } | 106 } |
OLD | NEW |