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

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

Issue 9645003: Introduce abstractions to allow embedders to test RenderViewHost (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head. Created 8 years, 9 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/time.h" 6 #include "base/time.h"
7 #include "content/browser/debugger/devtools_manager_impl.h" 7 #include "content/browser/debugger/devtools_manager_impl.h"
8 #include "content/browser/debugger/render_view_devtools_agent_host.h" 8 #include "content/browser/debugger/render_view_devtools_agent_host.h"
9 #include "content/browser/mock_content_browser_client.h" 9 #include "content/browser/mock_content_browser_client.h"
10 #include "content/browser/renderer_host/test_render_view_host.h" 10 #include "content/browser/renderer_host/test_render_view_host.h"
11 #include "content/browser/tab_contents/test_tab_contents.h" 11 #include "content/browser/tab_contents/test_tab_contents.h"
12 #include "content/common/view_messages.h" 12 #include "content/common/view_messages.h"
13 #include "content/public/browser/content_browser_client.h" 13 #include "content/public/browser/content_browser_client.h"
14 #include "content/public/browser/devtools_agent_host_registry.h" 14 #include "content/public/browser/devtools_agent_host_registry.h"
15 #include "content/public/browser/devtools_client_host.h" 15 #include "content/public/browser/devtools_client_host.h"
16 #include "content/public/browser/web_contents_delegate.h" 16 #include "content/public/browser/web_contents_delegate.h"
17 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
18 18
19 using base::TimeDelta; 19 using base::TimeDelta;
20 using content::DevToolsAgentHost; 20 using content::DevToolsAgentHost;
21 using content::DevToolsAgentHostRegistry; 21 using content::DevToolsAgentHostRegistry;
22 using content::DevToolsClientHost; 22 using content::DevToolsClientHost;
23 using content::DevToolsManager; 23 using content::DevToolsManager;
24 using content::DevToolsManagerImpl; 24 using content::DevToolsManagerImpl;
25 using content::RenderViewHostImplTestHarness;
25 using content::WebContents; 26 using content::WebContents;
26 27
27 namespace { 28 namespace {
28 29
29 class TestDevToolsClientHost : public DevToolsClientHost { 30 class TestDevToolsClientHost : public DevToolsClientHost {
30 public: 31 public:
31 TestDevToolsClientHost() 32 TestDevToolsClientHost()
32 : last_sent_message(NULL), 33 : last_sent_message(NULL),
33 closed_(false) { 34 closed_(false) {
34 } 35 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 const GURL& new_url) OVERRIDE { 105 const GURL& new_url) OVERRIDE {
105 return true; 106 return true;
106 } 107 }
107 108
108 private: 109 private:
109 DISALLOW_COPY_AND_ASSIGN(DevToolsManagerTestBrowserClient); 110 DISALLOW_COPY_AND_ASSIGN(DevToolsManagerTestBrowserClient);
110 }; 111 };
111 112
112 } // namespace 113 } // namespace
113 114
114 class DevToolsManagerTest : public RenderViewHostTestHarness { 115 class DevToolsManagerTest : public RenderViewHostImplTestHarness {
115 public: 116 public:
116 DevToolsManagerTest() : RenderViewHostTestHarness() { 117 DevToolsManagerTest() {
117 } 118 }
118 119
119 protected: 120 protected:
120 virtual void SetUp() OVERRIDE { 121 virtual void SetUp() OVERRIDE {
121 original_browser_client_ = content::GetContentClient()->browser(); 122 original_browser_client_ = content::GetContentClient()->browser();
122 content::GetContentClient()->set_browser(&browser_client_); 123 content::GetContentClient()->set_browser(&browser_client_);
123 124
124 RenderViewHostTestHarness::SetUp(); 125 RenderViewHostTestHarness::SetUp();
125 TestDevToolsClientHost::ResetCounters(); 126 TestDevToolsClientHost::ResetCounters();
126 } 127 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 std::string m = "test message"; 174 std::string m = "test message";
174 agent_host = DevToolsAgentHostRegistry::GetDevToolsAgentHost(rvh()); 175 agent_host = DevToolsAgentHostRegistry::GetDevToolsAgentHost(rvh());
175 manager.DispatchOnInspectorFrontend(agent_host, m); 176 manager.DispatchOnInspectorFrontend(agent_host, m);
176 EXPECT_TRUE(&m == client_host.last_sent_message); 177 EXPECT_TRUE(&m == client_host.last_sent_message);
177 178
178 client_host.Close(&manager); 179 client_host.Close(&manager);
179 EXPECT_EQ(1, TestDevToolsClientHost::close_counter); 180 EXPECT_EQ(1, TestDevToolsClientHost::close_counter);
180 } 181 }
181 182
182 TEST_F(DevToolsManagerTest, NoUnresponsiveDialogInInspectedTab) { 183 TEST_F(DevToolsManagerTest, NoUnresponsiveDialogInInspectedTab) {
183 content::TestRenderViewHost* inspected_rvh = rvh(); 184 content::TestRenderViewHost* inspected_rvh = test_rvh();
184 inspected_rvh->set_render_view_created(true); 185 inspected_rvh->set_render_view_created(true);
185 EXPECT_FALSE(contents()->GetDelegate()); 186 EXPECT_FALSE(contents()->GetDelegate());
186 TestWebContentsDelegate delegate; 187 TestWebContentsDelegate delegate;
187 contents()->SetDelegate(&delegate); 188 contents()->SetDelegate(&delegate);
188 189
189 TestDevToolsClientHost client_host; 190 TestDevToolsClientHost client_host;
190 DevToolsAgentHost* agent_host = 191 DevToolsAgentHost* agent_host =
191 DevToolsAgentHostRegistry::GetDevToolsAgentHost(inspected_rvh); 192 DevToolsAgentHostRegistry::GetDevToolsAgentHost(inspected_rvh);
192 DevToolsManager::GetInstance()-> 193 DevToolsManager::GetInstance()->
193 RegisterDevToolsClientHostFor(agent_host, &client_host); 194 RegisterDevToolsClientHostFor(agent_host, &client_host);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 239
239 // Interrupt pending navigation and navigate back to the original site. 240 // Interrupt pending navigation and navigate back to the original site.
240 controller().LoadURL( 241 controller().LoadURL(
241 url, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); 242 url, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string());
242 contents()->TestDidNavigate(rvh(), 1, url, content::PAGE_TRANSITION_TYPED); 243 contents()->TestDidNavigate(rvh(), 1, url, content::PAGE_TRANSITION_TYPED);
243 EXPECT_FALSE(contents()->cross_navigation_pending()); 244 EXPECT_FALSE(contents()->cross_navigation_pending());
244 EXPECT_EQ(&client_host, devtools_manager->GetDevToolsClientHostFor( 245 EXPECT_EQ(&client_host, devtools_manager->GetDevToolsClientHostFor(
245 DevToolsAgentHostRegistry::GetDevToolsAgentHost(rvh()))); 246 DevToolsAgentHostRegistry::GetDevToolsAgentHost(rvh())));
246 client_host.Close(DevToolsManager::GetInstance()); 247 client_host.Close(DevToolsManager::GetInstance());
247 } 248 }
OLDNEW
« no previous file with comments | « chrome/test/base/chrome_render_view_host_test_harness.cc ('k') | content/browser/renderer_host/render_view_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698