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 "content/public/test/test_renderer_host.h" | 5 #include "content/public/test/test_renderer_host.h" |
6 | 6 |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "content/browser/frame_host/navigation_entry_impl.h" | 8 #include "content/browser/frame_host/navigation_entry_impl.h" |
9 #include "content/browser/renderer_host/render_view_host_factory.h" | 9 #include "content/browser/renderer_host/render_view_host_factory.h" |
10 #include "content/browser/renderer_host/render_widget_host_impl.h" | 10 #include "content/browser/renderer_host/render_widget_host_impl.h" |
11 #include "content/browser/site_instance_impl.h" | 11 #include "content/browser/site_instance_impl.h" |
12 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
13 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
14 #include "content/public/test/mock_render_process_host.h" | 14 #include "content/public/test/mock_render_process_host.h" |
15 #include "content/public/test/test_browser_context.h" | 15 #include "content/public/test/test_browser_context.h" |
16 #include "content/test/test_render_frame_host_factory.h" | 16 #include "content/test/test_render_frame_host_factory.h" |
17 #include "content/test/test_render_view_host.h" | 17 #include "content/test/test_render_view_host.h" |
18 #include "content/test/test_render_view_host_factory.h" | 18 #include "content/test/test_render_view_host_factory.h" |
19 #include "content/test/test_web_contents.h" | 19 #include "content/test/test_web_contents.h" |
20 | 20 |
21 #if defined(OS_WIN) | 21 #if defined(OS_WIN) |
22 #include "ui/base/win/scoped_ole_initializer.h" | 22 #include "ui/base/win/scoped_ole_initializer.h" |
23 #endif | 23 #endif |
24 | 24 |
25 #if defined(USE_AURA) | 25 #if defined(USE_AURA) |
| 26 #include "ui/aura/test/aura_test_helper.h" |
26 #include "ui/compositor/test/context_factories_for_test.h" | 27 #include "ui/compositor/test/context_factories_for_test.h" |
27 #include "ui/wm/test/wm_test_helper.h" | |
28 #endif | 28 #endif |
29 | 29 |
30 namespace content { | 30 namespace content { |
31 | 31 |
32 // RenderViewHostTester ------------------------------------------------------- | 32 // RenderViewHostTester ------------------------------------------------------- |
33 | 33 |
34 // static | 34 // static |
35 RenderViewHostTester* RenderViewHostTester::For(RenderViewHost* host) { | 35 RenderViewHostTester* RenderViewHostTester::For(RenderViewHost* host) { |
36 return static_cast<TestRenderViewHost*>(host); | 36 return static_cast<TestRenderViewHost*>(host); |
37 } | 37 } |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 void RenderViewHostTestHarness::SetContents(WebContents* contents) { | 124 void RenderViewHostTestHarness::SetContents(WebContents* contents) { |
125 contents_.reset(contents); | 125 contents_.reset(contents); |
126 } | 126 } |
127 | 127 |
128 WebContents* RenderViewHostTestHarness::CreateTestWebContents() { | 128 WebContents* RenderViewHostTestHarness::CreateTestWebContents() { |
129 // Make sure we ran SetUp() already. | 129 // Make sure we ran SetUp() already. |
130 #if defined(OS_WIN) | 130 #if defined(OS_WIN) |
131 DCHECK(ole_initializer_ != NULL); | 131 DCHECK(ole_initializer_ != NULL); |
132 #endif | 132 #endif |
133 #if defined(USE_AURA) | 133 #if defined(USE_AURA) |
134 DCHECK(wm_test_helper_ != NULL); | 134 DCHECK(aura_test_helper_ != NULL); |
135 #endif | 135 #endif |
136 | 136 |
137 // This will be deleted when the WebContentsImpl goes away. | 137 // This will be deleted when the WebContentsImpl goes away. |
138 SiteInstance* instance = SiteInstance::Create(browser_context_.get()); | 138 SiteInstance* instance = SiteInstance::Create(browser_context_.get()); |
139 | 139 |
140 return TestWebContents::Create(browser_context_.get(), instance); | 140 return TestWebContents::Create(browser_context_.get(), instance); |
141 } | 141 } |
142 | 142 |
143 void RenderViewHostTestHarness::NavigateAndCommit(const GURL& url) { | 143 void RenderViewHostTestHarness::NavigateAndCommit(const GURL& url) { |
144 static_cast<TestWebContents*>(web_contents())->NavigateAndCommit(url); | 144 static_cast<TestWebContents*>(web_contents())->NavigateAndCommit(url); |
(...skipping 19 matching lines...) Expand all Loading... |
164 thread_bundle_.reset(new TestBrowserThreadBundle(thread_bundle_options_)); | 164 thread_bundle_.reset(new TestBrowserThreadBundle(thread_bundle_options_)); |
165 | 165 |
166 #if defined(OS_WIN) | 166 #if defined(OS_WIN) |
167 ole_initializer_.reset(new ui::ScopedOleInitializer()); | 167 ole_initializer_.reset(new ui::ScopedOleInitializer()); |
168 #endif | 168 #endif |
169 #if defined(USE_AURA) | 169 #if defined(USE_AURA) |
170 // The ContextFactory must exist before any Compositors are created. | 170 // The ContextFactory must exist before any Compositors are created. |
171 bool enable_pixel_output = false; | 171 bool enable_pixel_output = false; |
172 ui::InitializeContextFactoryForTests(enable_pixel_output); | 172 ui::InitializeContextFactoryForTests(enable_pixel_output); |
173 | 173 |
174 wm_test_helper_.reset(new wm::WMTestHelper); | 174 aura_test_helper_.reset( |
175 wm_test_helper_->SetUp(); | 175 new aura::test::AuraTestHelper(base::MessageLoopForUI::current())); |
| 176 aura_test_helper_->SetUp(); |
176 #endif | 177 #endif |
177 | 178 |
178 DCHECK(!browser_context_); | 179 DCHECK(!browser_context_); |
179 browser_context_.reset(CreateBrowserContext()); | 180 browser_context_.reset(CreateBrowserContext()); |
180 | 181 |
181 SetContents(CreateTestWebContents()); | 182 SetContents(CreateTestWebContents()); |
182 } | 183 } |
183 | 184 |
184 void RenderViewHostTestHarness::TearDown() { | 185 void RenderViewHostTestHarness::TearDown() { |
185 SetContents(NULL); | 186 SetContents(NULL); |
186 #if defined(USE_AURA) | 187 #if defined(USE_AURA) |
187 wm_test_helper_->TearDown(); | 188 aura_test_helper_->TearDown(); |
188 ui::TerminateContextFactoryForTests(); | 189 ui::TerminateContextFactoryForTests(); |
189 #endif | 190 #endif |
190 // Make sure that we flush any messages related to WebContentsImpl destruction | 191 // Make sure that we flush any messages related to WebContentsImpl destruction |
191 // before we destroy the browser context. | 192 // before we destroy the browser context. |
192 base::RunLoop().RunUntilIdle(); | 193 base::RunLoop().RunUntilIdle(); |
193 | 194 |
194 #if defined(OS_WIN) | 195 #if defined(OS_WIN) |
195 ole_initializer_.reset(); | 196 ole_initializer_.reset(); |
196 #endif | 197 #endif |
197 | 198 |
(...skipping 14 matching lines...) Expand all Loading... |
212 BrowserContext* RenderViewHostTestHarness::CreateBrowserContext() { | 213 BrowserContext* RenderViewHostTestHarness::CreateBrowserContext() { |
213 return new TestBrowserContext(); | 214 return new TestBrowserContext(); |
214 } | 215 } |
215 | 216 |
216 void RenderViewHostTestHarness::SetRenderProcessHostFactory( | 217 void RenderViewHostTestHarness::SetRenderProcessHostFactory( |
217 RenderProcessHostFactory* factory) { | 218 RenderProcessHostFactory* factory) { |
218 rvh_test_enabler_.rvh_factory_->set_render_process_host_factory(factory); | 219 rvh_test_enabler_.rvh_factory_->set_render_process_host_factory(factory); |
219 } | 220 } |
220 | 221 |
221 } // namespace content | 222 } // namespace content |
OLD | NEW |