| 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 | 93 int process_id = 0; |
| 94 tab->NavigateToURLAsync(GURL("about:crash")); | 94 ASSERT_TRUE(tab->GetProcessID(&process_id)); |
| 95 ASSERT_NE(0, process_id); |
| 96 base::ProcessHandle process_handle; |
| 97 ASSERT_TRUE(base::OpenProcessHandle(process_id, &process_handle)); |
| 98 // Fake Access Violation. |
| 99 base::KillProcess(process_handle, 0xc0000005, true); |
| 100 base::CloseProcessHandle(process_handle); |
| 95 | 101 |
| 96 // Give the browser a chance to notice the crashed tab. | 102 // Give the browser a chance to notice the crashed tab. |
| 97 PlatformThread::Sleep(1000); | 103 PlatformThread::Sleep(1000); |
| 98 | 104 |
| 99 QuitBrowser(); | 105 QuitBrowser(); |
| 100 | 106 |
| 101 scoped_ptr<PrefService> local_state(GetLocalState()); | 107 scoped_ptr<PrefService> local_state(GetLocalState()); |
| 102 local_state->RegisterBooleanPref(prefs::kStabilityExitedCleanly, true); | 108 local_state->RegisterBooleanPref(prefs::kStabilityExitedCleanly, true); |
| 103 local_state->RegisterIntegerPref(prefs::kStabilityLaunchCount, 0); | 109 local_state->RegisterIntegerPref(prefs::kStabilityLaunchCount, 0); |
| 104 local_state->RegisterIntegerPref(prefs::kStabilityPageLoadCount, 0); | 110 local_state->RegisterIntegerPref(prefs::kStabilityPageLoadCount, 0); |
| 105 local_state->RegisterIntegerPref(prefs::kStabilityRendererCrashCount, 0); | 111 local_state->RegisterIntegerPref(prefs::kStabilityRendererCrashCount, 0); |
| 106 EXPECT_TRUE(local_state->GetBoolean(prefs::kStabilityExitedCleanly)); | 112 EXPECT_TRUE(local_state->GetBoolean(prefs::kStabilityExitedCleanly)); |
| 107 EXPECT_EQ(1, local_state->GetInteger(prefs::kStabilityLaunchCount)); | 113 EXPECT_EQ(1, local_state->GetInteger(prefs::kStabilityLaunchCount)); |
| 108 EXPECT_EQ(4, local_state->GetInteger(prefs::kStabilityPageLoadCount)); | 114 EXPECT_EQ(3, local_state->GetInteger(prefs::kStabilityPageLoadCount)); |
| 109 EXPECT_EQ(1, local_state->GetInteger(prefs::kStabilityRendererCrashCount)); | 115 EXPECT_EQ(1, local_state->GetInteger(prefs::kStabilityRendererCrashCount)); |
| 110 } | 116 } |
| OLD | NEW |