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 #include "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "base/time.h" | 7 #include "base/time.h" |
8 #include "content/browser/devtools/devtools_manager_impl.h" | 8 #include "content/browser/devtools/devtools_manager_impl.h" |
9 #include "content/browser/devtools/render_view_devtools_agent_host.h" | 9 #include "content/browser/devtools/render_view_devtools_agent_host.h" |
10 #include "content/browser/renderer_host/test_render_view_host.h" | 10 #include "content/browser/renderer_host/test_render_view_host.h" |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 | 174 |
175 TestDevToolsClientHost client_host; | 175 TestDevToolsClientHost client_host; |
176 scoped_refptr<DevToolsAgentHost> agent_host( | 176 scoped_refptr<DevToolsAgentHost> agent_host( |
177 DevToolsAgentHost::GetOrCreateFor(inspected_rvh)); | 177 DevToolsAgentHost::GetOrCreateFor(inspected_rvh)); |
178 DevToolsManager::GetInstance()-> | 178 DevToolsManager::GetInstance()-> |
179 RegisterDevToolsClientHostFor(agent_host, &client_host); | 179 RegisterDevToolsClientHostFor(agent_host, &client_host); |
180 | 180 |
181 // Start with a short timeout. | 181 // Start with a short timeout. |
182 inspected_rvh->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10)); | 182 inspected_rvh->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10)); |
183 // Wait long enough for first timeout and see if it fired. | 183 // Wait long enough for first timeout and see if it fired. |
184 MessageLoop::current()->PostDelayedTask( | 184 base::MessageLoop::current()->PostDelayedTask( |
185 FROM_HERE, MessageLoop::QuitClosure(), TimeDelta::FromMilliseconds(10)); | 185 FROM_HERE, |
186 MessageLoop::current()->Run(); | 186 base::MessageLoop::QuitClosure(), |
| 187 TimeDelta::FromMilliseconds(10)); |
| 188 base::MessageLoop::current()->Run(); |
187 EXPECT_FALSE(delegate.renderer_unresponsive_received()); | 189 EXPECT_FALSE(delegate.renderer_unresponsive_received()); |
188 | 190 |
189 // Now close devtools and check that the notification is delivered. | 191 // Now close devtools and check that the notification is delivered. |
190 client_host.Close(DevToolsManager::GetInstance()); | 192 client_host.Close(DevToolsManager::GetInstance()); |
191 // Start with a short timeout. | 193 // Start with a short timeout. |
192 inspected_rvh->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10)); | 194 inspected_rvh->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10)); |
193 // Wait long enough for first timeout and see if it fired. | 195 // Wait long enough for first timeout and see if it fired. |
194 MessageLoop::current()->PostDelayedTask( | 196 base::MessageLoop::current()->PostDelayedTask( |
195 FROM_HERE, MessageLoop::QuitClosure(), TimeDelta::FromMilliseconds(10)); | 197 FROM_HERE, |
196 MessageLoop::current()->Run(); | 198 base::MessageLoop::QuitClosure(), |
| 199 TimeDelta::FromMilliseconds(10)); |
| 200 base::MessageLoop::current()->Run(); |
197 EXPECT_TRUE(delegate.renderer_unresponsive_received()); | 201 EXPECT_TRUE(delegate.renderer_unresponsive_received()); |
198 | 202 |
199 contents()->SetDelegate(NULL); | 203 contents()->SetDelegate(NULL); |
200 } | 204 } |
201 | 205 |
202 TEST_F(DevToolsManagerTest, ReattachOnCancelPendingNavigation) { | 206 TEST_F(DevToolsManagerTest, ReattachOnCancelPendingNavigation) { |
203 contents()->transition_cross_site = true; | 207 contents()->transition_cross_site = true; |
204 // Navigate to URL. First URL should use first RenderViewHost. | 208 // Navigate to URL. First URL should use first RenderViewHost. |
205 const GURL url("http://www.google.com"); | 209 const GURL url("http://www.google.com"); |
206 controller().LoadURL( | 210 controller().LoadURL( |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 manager->RegisterDevToolsClientHostFor(agent_host, &client_host); | 286 manager->RegisterDevToolsClientHostFor(agent_host, &client_host); |
283 | 287 |
284 manager->DispatchOnInspectorBackend(&client_host, "message1"); | 288 manager->DispatchOnInspectorBackend(&client_host, "message1"); |
285 manager->DispatchOnInspectorBackend(&client_host, "message2"); | 289 manager->DispatchOnInspectorBackend(&client_host, "message2"); |
286 manager->DispatchOnInspectorBackend(&client_host, "message2"); | 290 manager->DispatchOnInspectorBackend(&client_host, "message2"); |
287 | 291 |
288 client_host.Close(manager); | 292 client_host.Close(manager); |
289 } | 293 } |
290 | 294 |
291 } // namespace content | 295 } // namespace content |
OLD | NEW |