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