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/aura/test/aura_test_helper.h" |
| 27 #include "ui/compositor/test/context_factories_for_test.h" |
27 #endif | 28 #endif |
28 | 29 |
29 namespace content { | 30 namespace content { |
30 | 31 |
31 // RenderViewHostTester ------------------------------------------------------- | 32 // RenderViewHostTester ------------------------------------------------------- |
32 | 33 |
33 // static | 34 // static |
34 RenderViewHostTester* RenderViewHostTester::For(RenderViewHost* host) { | 35 RenderViewHostTester* RenderViewHostTester::For(RenderViewHost* host) { |
35 return static_cast<TestRenderViewHost*>(host); | 36 return static_cast<TestRenderViewHost*>(host); |
36 } | 37 } |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 rvh())->SendFailedNavigate(entry->GetPageID(), entry->GetURL()); | 159 rvh())->SendFailedNavigate(entry->GetPageID(), entry->GetURL()); |
159 } | 160 } |
160 | 161 |
161 void RenderViewHostTestHarness::SetUp() { | 162 void RenderViewHostTestHarness::SetUp() { |
162 thread_bundle_.reset(new TestBrowserThreadBundle(thread_bundle_options_)); | 163 thread_bundle_.reset(new TestBrowserThreadBundle(thread_bundle_options_)); |
163 | 164 |
164 #if defined(OS_WIN) | 165 #if defined(OS_WIN) |
165 ole_initializer_.reset(new ui::ScopedOleInitializer()); | 166 ole_initializer_.reset(new ui::ScopedOleInitializer()); |
166 #endif | 167 #endif |
167 #if defined(USE_AURA) | 168 #if defined(USE_AURA) |
| 169 // The ContextFactory must exist before any Compositors are created. |
| 170 bool enable_pixel_output = false; |
| 171 ui::InitializeContextFactoryForTests(enable_pixel_output); |
| 172 |
168 aura_test_helper_.reset( | 173 aura_test_helper_.reset( |
169 new aura::test::AuraTestHelper(base::MessageLoopForUI::current())); | 174 new aura::test::AuraTestHelper(base::MessageLoopForUI::current())); |
170 bool allow_test_contexts = true; | 175 aura_test_helper_->SetUp(); |
171 aura_test_helper_->SetUp(allow_test_contexts); | |
172 #endif | 176 #endif |
173 | 177 |
174 DCHECK(!browser_context_); | 178 DCHECK(!browser_context_); |
175 browser_context_.reset(CreateBrowserContext()); | 179 browser_context_.reset(CreateBrowserContext()); |
176 | 180 |
177 SetContents(CreateTestWebContents()); | 181 SetContents(CreateTestWebContents()); |
178 } | 182 } |
179 | 183 |
180 void RenderViewHostTestHarness::TearDown() { | 184 void RenderViewHostTestHarness::TearDown() { |
181 SetContents(NULL); | 185 SetContents(NULL); |
182 #if defined(USE_AURA) | 186 #if defined(USE_AURA) |
183 aura_test_helper_->TearDown(); | 187 aura_test_helper_->TearDown(); |
| 188 ui::TerminateContextFactoryForTests(); |
184 #endif | 189 #endif |
185 // Make sure that we flush any messages related to WebContentsImpl destruction | 190 // Make sure that we flush any messages related to WebContentsImpl destruction |
186 // before we destroy the browser context. | 191 // before we destroy the browser context. |
187 base::RunLoop().RunUntilIdle(); | 192 base::RunLoop().RunUntilIdle(); |
188 | 193 |
189 #if defined(OS_WIN) | 194 #if defined(OS_WIN) |
190 ole_initializer_.reset(); | 195 ole_initializer_.reset(); |
191 #endif | 196 #endif |
192 | 197 |
193 // Delete any RenderProcessHosts before the BrowserContext goes away. | 198 // Delete any RenderProcessHosts before the BrowserContext goes away. |
(...skipping 13 matching lines...) Expand all Loading... |
207 BrowserContext* RenderViewHostTestHarness::CreateBrowserContext() { | 212 BrowserContext* RenderViewHostTestHarness::CreateBrowserContext() { |
208 return new TestBrowserContext(); | 213 return new TestBrowserContext(); |
209 } | 214 } |
210 | 215 |
211 void RenderViewHostTestHarness::SetRenderProcessHostFactory( | 216 void RenderViewHostTestHarness::SetRenderProcessHostFactory( |
212 RenderProcessHostFactory* factory) { | 217 RenderProcessHostFactory* factory) { |
213 rvh_test_enabler_.rvh_factory_->set_render_process_host_factory(factory); | 218 rvh_test_enabler_.rvh_factory_->set_render_process_host_factory(factory); |
214 } | 219 } |
215 | 220 |
216 } // namespace content | 221 } // namespace content |
OLD | NEW |