OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/time.h" | 6 #include "base/time.h" |
7 #include "content/browser/debugger/devtools_client_host.h" | 7 #include "content/browser/debugger/devtools_client_host.h" |
8 #include "content/browser/debugger/devtools_manager.h" | 8 #include "content/browser/debugger/devtools_manager.h" |
9 #include "content/browser/debugger/render_view_devtools_agent_host.h" | 9 #include "content/browser/debugger/render_view_devtools_agent_host.h" |
10 #include "content/browser/mock_content_browser_client.h" | 10 #include "content/browser/mock_content_browser_client.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 private: | 85 private: |
86 bool renderer_unresponsive_received_; | 86 bool renderer_unresponsive_received_; |
87 }; | 87 }; |
88 | 88 |
89 class DevToolsManagerTestBrowserClient | 89 class DevToolsManagerTestBrowserClient |
90 : public content::MockContentBrowserClient { | 90 : public content::MockContentBrowserClient { |
91 public: | 91 public: |
92 DevToolsManagerTestBrowserClient() { | 92 DevToolsManagerTestBrowserClient() { |
93 } | 93 } |
94 | 94 |
95 virtual DevToolsManager* GetDevToolsManager() OVERRIDE { | |
96 return &dev_tools_manager_; | |
97 } | |
98 | |
99 virtual bool ShouldSwapProcessesForNavigation( | 95 virtual bool ShouldSwapProcessesForNavigation( |
100 const GURL& current_url, | 96 const GURL& current_url, |
101 const GURL& new_url) OVERRIDE { | 97 const GURL& new_url) OVERRIDE { |
102 return true; | 98 return true; |
103 } | 99 } |
104 | 100 |
105 private: | 101 private: |
106 DevToolsManager dev_tools_manager_; | |
107 | |
108 DISALLOW_COPY_AND_ASSIGN(DevToolsManagerTestBrowserClient); | 102 DISALLOW_COPY_AND_ASSIGN(DevToolsManagerTestBrowserClient); |
109 }; | 103 }; |
110 | 104 |
111 } // namespace | 105 } // namespace |
112 | 106 |
113 class DevToolsManagerTest : public RenderViewHostTestHarness { | 107 class DevToolsManagerTest : public RenderViewHostTestHarness { |
114 public: | 108 public: |
115 DevToolsManagerTest() : RenderViewHostTestHarness() { | 109 DevToolsManagerTest() : RenderViewHostTestHarness() { |
116 } | 110 } |
117 | 111 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 } | 169 } |
176 | 170 |
177 TEST_F(DevToolsManagerTest, NoUnresponsiveDialogInInspectedTab) { | 171 TEST_F(DevToolsManagerTest, NoUnresponsiveDialogInInspectedTab) { |
178 TestRenderViewHost* inspected_rvh = rvh(); | 172 TestRenderViewHost* inspected_rvh = rvh(); |
179 inspected_rvh->set_render_view_created(true); | 173 inspected_rvh->set_render_view_created(true); |
180 EXPECT_FALSE(contents()->delegate()); | 174 EXPECT_FALSE(contents()->delegate()); |
181 TestTabContentsDelegate delegate; | 175 TestTabContentsDelegate delegate; |
182 contents()->set_delegate(&delegate); | 176 contents()->set_delegate(&delegate); |
183 | 177 |
184 TestDevToolsClientHost client_host; | 178 TestDevToolsClientHost client_host; |
185 content::GetContentClient()->browser()->GetDevToolsManager()-> | 179 DevToolsManager::GetInstance()-> |
186 RegisterDevToolsClientHostFor(inspected_rvh, &client_host); | 180 RegisterDevToolsClientHostFor(inspected_rvh, &client_host); |
187 | 181 |
188 // Start with a short timeout. | 182 // Start with a short timeout. |
189 inspected_rvh->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10)); | 183 inspected_rvh->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10)); |
190 // Wait long enough for first timeout and see if it fired. | 184 // Wait long enough for first timeout and see if it fired. |
191 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 185 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
192 new MessageLoop::QuitTask(), 10); | 186 new MessageLoop::QuitTask(), 10); |
193 MessageLoop::current()->Run(); | 187 MessageLoop::current()->Run(); |
194 EXPECT_FALSE(delegate.renderer_unresponsive_received()); | 188 EXPECT_FALSE(delegate.renderer_unresponsive_received()); |
195 | 189 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 devtools_manager->GetDevToolsClientHostFor(pending_rvh())); | 225 devtools_manager->GetDevToolsClientHostFor(pending_rvh())); |
232 | 226 |
233 // Interrupt pending navigation and navigate back to the original site. | 227 // Interrupt pending navigation and navigate back to the original site. |
234 controller().LoadURL( | 228 controller().LoadURL( |
235 url, GURL(), content::PAGE_TRANSITION_TYPED, std::string()); | 229 url, GURL(), content::PAGE_TRANSITION_TYPED, std::string()); |
236 contents()->TestDidNavigate(orig_rvh, params1); | 230 contents()->TestDidNavigate(orig_rvh, params1); |
237 EXPECT_FALSE(contents()->cross_navigation_pending()); | 231 EXPECT_FALSE(contents()->cross_navigation_pending()); |
238 EXPECT_EQ(&client_host, devtools_manager->GetDevToolsClientHostFor(rvh())); | 232 EXPECT_EQ(&client_host, devtools_manager->GetDevToolsClientHostFor(rvh())); |
239 client_host.Close(); | 233 client_host.Close(); |
240 } | 234 } |
OLD | NEW |