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

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

Issue 10479023: Simplify how Content*Client interfaces are created. Instead of depending on the embedder to know wh… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: remove unused function declaration Created 8 years, 6 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"
10 #include "content/browser/renderer_host/test_render_view_host.h" 9 #include "content/browser/renderer_host/test_render_view_host.h"
11 #include "content/browser/web_contents/test_web_contents.h" 10 #include "content/browser/web_contents/test_web_contents.h"
12 #include "content/common/view_messages.h" 11 #include "content/common/view_messages.h"
13 #include "content/public/browser/content_browser_client.h" 12 #include "content/public/browser/content_browser_client.h"
14 #include "content/public/browser/devtools_agent_host_registry.h" 13 #include "content/public/browser/devtools_agent_host_registry.h"
15 #include "content/public/browser/devtools_client_host.h" 14 #include "content/public/browser/devtools_client_host.h"
16 #include "content/public/browser/web_contents_delegate.h" 15 #include "content/public/browser/web_contents_delegate.h"
16 #include "content/test/test_content_browser_client.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::RenderViewHostImplTestHarness;
26 using content::WebContents; 26 using content::WebContents;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 85
86 bool renderer_unresponsive_received() const { 86 bool renderer_unresponsive_received() const {
87 return renderer_unresponsive_received_; 87 return renderer_unresponsive_received_;
88 } 88 }
89 89
90 private: 90 private:
91 bool renderer_unresponsive_received_; 91 bool renderer_unresponsive_received_;
92 }; 92 };
93 93
94 class DevToolsManagerTestBrowserClient 94 class DevToolsManagerTestBrowserClient
95 : public content::MockContentBrowserClient { 95 : public content::TestContentBrowserClient {
96 public: 96 public:
97 DevToolsManagerTestBrowserClient() { 97 DevToolsManagerTestBrowserClient() {
98 } 98 }
99 99
100 virtual bool ShouldSwapBrowsingInstanceForNavigation( 100 virtual bool ShouldSwapBrowsingInstanceForNavigation(
101 content::BrowserContext* browser_context, 101 content::BrowserContext* browser_context,
102 const GURL& current_url, 102 const GURL& current_url,
103 const GURL& new_url) OVERRIDE { 103 const GURL& new_url) OVERRIDE {
104 return true; 104 return true;
105 } 105 }
106 106
107 private: 107 private:
108 DISALLOW_COPY_AND_ASSIGN(DevToolsManagerTestBrowserClient); 108 DISALLOW_COPY_AND_ASSIGN(DevToolsManagerTestBrowserClient);
109 }; 109 };
110 110
111 } // namespace 111 } // namespace
112 112
113 class DevToolsManagerTest : public RenderViewHostImplTestHarness { 113 class DevToolsManagerTest : public RenderViewHostImplTestHarness {
114 public: 114 public:
115 DevToolsManagerTest() { 115 DevToolsManagerTest() {
116 } 116 }
117 117
118 protected: 118 protected:
119 virtual void SetUp() OVERRIDE { 119 virtual void SetUp() OVERRIDE {
120 original_browser_client_ = content::GetContentClient()->browser(); 120 original_browser_client_ = content::GetContentClient()->browser();
121 content::GetContentClient()->set_browser(&browser_client_); 121 content::GetContentClient()->set_browser_for_testing(&browser_client_);
122 122
123 RenderViewHostImplTestHarness::SetUp(); 123 RenderViewHostImplTestHarness::SetUp();
124 TestDevToolsClientHost::ResetCounters(); 124 TestDevToolsClientHost::ResetCounters();
125 } 125 }
126 126
127 virtual void TearDown() OVERRIDE { 127 virtual void TearDown() OVERRIDE {
128 RenderViewHostImplTestHarness::TearDown(); 128 RenderViewHostImplTestHarness::TearDown();
129 content::GetContentClient()->set_browser(original_browser_client_); 129 content::GetContentClient()->set_browser_for_testing(
130 original_browser_client_);
130 } 131 }
131 132
132 private: 133 private:
133 content::ContentBrowserClient* original_browser_client_; 134 content::ContentBrowserClient* original_browser_client_;
134 DevToolsManagerTestBrowserClient browser_client_; 135 DevToolsManagerTestBrowserClient browser_client_;
135 }; 136 };
136 137
137 TEST_F(DevToolsManagerTest, OpenAndManuallyCloseDevToolsClientHost) { 138 TEST_F(DevToolsManagerTest, OpenAndManuallyCloseDevToolsClientHost) {
138 DevToolsManagerImpl manager; 139 DevToolsManagerImpl manager;
139 140
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 238
238 // Interrupt pending navigation and navigate back to the original site. 239 // Interrupt pending navigation and navigate back to the original site.
239 controller().LoadURL( 240 controller().LoadURL(
240 url, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); 241 url, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string());
241 contents()->TestDidNavigate(rvh(), 1, url, content::PAGE_TRANSITION_TYPED); 242 contents()->TestDidNavigate(rvh(), 1, url, content::PAGE_TRANSITION_TYPED);
242 EXPECT_FALSE(contents()->cross_navigation_pending()); 243 EXPECT_FALSE(contents()->cross_navigation_pending());
243 EXPECT_EQ(&client_host, devtools_manager->GetDevToolsClientHostFor( 244 EXPECT_EQ(&client_host, devtools_manager->GetDevToolsClientHostFor(
244 DevToolsAgentHostRegistry::GetDevToolsAgentHost(rvh()))); 245 DevToolsAgentHostRegistry::GetDevToolsAgentHost(rvh())));
245 client_host.Close(DevToolsManager::GetInstance()); 246 client_host.Close(DevToolsManager::GetInstance());
246 } 247 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698