| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 // Flaky on Linux. See http://crbug.com/131094 | 72 // Flaky on Linux. See http://crbug.com/131094 |
| 73 #if defined(OS_LINUX) | 73 #if defined(OS_LINUX) |
| 74 #define MAYBE_CrashRenderers DISABLED_CrashRenderers | 74 #define MAYBE_CrashRenderers DISABLED_CrashRenderers |
| 75 #else | 75 #else |
| 76 #define MAYBE_CrashRenderers CrashRenderers | 76 #define MAYBE_CrashRenderers CrashRenderers |
| 77 #endif | 77 #endif |
| 78 IN_PROC_BROWSER_TEST_F(MetricsServiceTest, MAYBE_CrashRenderers) { | 78 IN_PROC_BROWSER_TEST_F(MetricsServiceTest, MAYBE_CrashRenderers) { |
| 79 OpenTabs(); | 79 OpenTabs(); |
| 80 | 80 |
| 81 // Kill the process for one of the tabs. | 81 // Kill the process for one of the tabs. |
| 82 ui_test_utils::WindowedNotificationObserver observer( | 82 content::WindowedNotificationObserver observer( |
| 83 content::NOTIFICATION_RENDERER_PROCESS_CLOSED, | 83 content::NOTIFICATION_RENDERER_PROCESS_CLOSED, |
| 84 content::NotificationService::AllSources()); | 84 content::NotificationService::AllSources()); |
| 85 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUICrashURL)); | 85 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUICrashURL)); |
| 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 ui_test_utils::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 |