Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Side by Side Diff: content/browser/devtools/devtools_manager_unittest.cc

Issue 14335017: content: Use base::MessageLoop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « content/browser/devtools/devtools_http_handler_unittest.cc ('k') | content/browser/download/base_file_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698