| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 TEST_F(MetricsServiceTest, CrashRenderers) { | 83 TEST_F(MetricsServiceTest, CrashRenderers) { |
| 84 // This doesn't make sense to test in single process mode. | 84 // This doesn't make sense to test in single process mode. |
| 85 if (in_process_renderer_) | 85 if (in_process_renderer_) |
| 86 return; | 86 return; |
| 87 | 87 |
| 88 OpenTabs(); | 88 OpenTabs(); |
| 89 | 89 |
| 90 // kill the process for one of the tabs | 90 // kill the process for one of the tabs |
| 91 scoped_refptr<TabProxy> tab(window_->GetTab(1)); | 91 scoped_refptr<TabProxy> tab(window_->GetTab(1)); |
| 92 ASSERT_TRUE(tab.get()); | 92 ASSERT_TRUE(tab.get()); |
| 93 int process_id = 0; | 93 |
| 94 ASSERT_TRUE(tab->GetProcessID(&process_id)); | 94 // Only windows implements the crash service for now. |
| 95 ASSERT_NE(0, process_id); | 95 #if defined(OS_WIN) |
| 96 base::ProcessHandle process_handle; | 96 expected_crashes_ = 1; |
| 97 ASSERT_TRUE(base::OpenProcessHandle(process_id, &process_handle)); | 97 #endif |
| 98 // Fake Access Violation. | 98 tab->NavigateToURLAsync(GURL("about:crash")); |
| 99 base::KillProcess(process_handle, 0xc0000005, true); | |
| 100 base::CloseProcessHandle(process_handle); | |
| 101 | 99 |
| 102 // Give the browser a chance to notice the crashed tab. | 100 // Give the browser a chance to notice the crashed tab. |
| 103 PlatformThread::Sleep(1000); | 101 PlatformThread::Sleep(1000); |
| 104 | 102 |
| 105 QuitBrowser(); | 103 QuitBrowser(); |
| 106 | 104 |
| 107 scoped_ptr<PrefService> local_state(GetLocalState()); | 105 scoped_ptr<PrefService> local_state(GetLocalState()); |
| 108 local_state->RegisterBooleanPref(prefs::kStabilityExitedCleanly, true); | 106 local_state->RegisterBooleanPref(prefs::kStabilityExitedCleanly, true); |
| 109 local_state->RegisterIntegerPref(prefs::kStabilityLaunchCount, 0); | 107 local_state->RegisterIntegerPref(prefs::kStabilityLaunchCount, 0); |
| 110 local_state->RegisterIntegerPref(prefs::kStabilityPageLoadCount, 0); | 108 local_state->RegisterIntegerPref(prefs::kStabilityPageLoadCount, 0); |
| 111 local_state->RegisterIntegerPref(prefs::kStabilityRendererCrashCount, 0); | 109 local_state->RegisterIntegerPref(prefs::kStabilityRendererCrashCount, 0); |
| 112 EXPECT_TRUE(local_state->GetBoolean(prefs::kStabilityExitedCleanly)); | 110 EXPECT_TRUE(local_state->GetBoolean(prefs::kStabilityExitedCleanly)); |
| 113 EXPECT_EQ(1, local_state->GetInteger(prefs::kStabilityLaunchCount)); | 111 EXPECT_EQ(1, local_state->GetInteger(prefs::kStabilityLaunchCount)); |
| 114 EXPECT_EQ(3, local_state->GetInteger(prefs::kStabilityPageLoadCount)); | 112 EXPECT_EQ(4, local_state->GetInteger(prefs::kStabilityPageLoadCount)); |
| 115 EXPECT_EQ(1, local_state->GetInteger(prefs::kStabilityRendererCrashCount)); | 113 EXPECT_EQ(1, local_state->GetInteger(prefs::kStabilityRendererCrashCount)); |
| 116 } | 114 } |
| OLD | NEW |