| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 #if defined(OS_WIN) | 30 #if defined(OS_WIN) |
| 31 #include "ui/base/win/scoped_ole_initializer.h" | 31 #include "ui/base/win/scoped_ole_initializer.h" |
| 32 #endif | 32 #endif |
| 33 | 33 |
| 34 #if defined(USE_AURA) | 34 #if defined(USE_AURA) |
| 35 #include "ui/aura/test/aura_test_helper.h" | 35 #include "ui/aura/test/aura_test_helper.h" |
| 36 #include "ui/compositor/test/context_factories_for_test.h" | 36 #include "ui/compositor/test/context_factories_for_test.h" |
| 37 #include "ui/wm/core/default_activation_client.h" | 37 #include "ui/wm/core/default_activation_client.h" |
| 38 #endif | 38 #endif |
| 39 | 39 |
| 40 #if defined(OS_MACOSX) | |
| 41 #include "ui/accelerated_widget_mac/window_resize_helper_mac.h" | |
| 42 #endif | |
| 43 | |
| 44 namespace content { | 40 namespace content { |
| 45 | 41 |
| 46 // RenderFrameHostTester ------------------------------------------------------ | 42 // RenderFrameHostTester ------------------------------------------------------ |
| 47 | 43 |
| 48 // static | 44 // static |
| 49 RenderFrameHostTester* RenderFrameHostTester::For(RenderFrameHost* host) { | 45 RenderFrameHostTester* RenderFrameHostTester::For(RenderFrameHost* host) { |
| 50 return static_cast<TestRenderFrameHost*>(host); | 46 return static_cast<TestRenderFrameHost*>(host); |
| 51 } | 47 } |
| 52 | 48 |
| 53 // static | 49 // static |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 | 204 |
| 209 sanity_checker_.reset(new ContentBrowserSanityChecker()); | 205 sanity_checker_.reset(new ContentBrowserSanityChecker()); |
| 210 | 206 |
| 211 DCHECK(!browser_context_); | 207 DCHECK(!browser_context_); |
| 212 browser_context_.reset(CreateBrowserContext()); | 208 browser_context_.reset(CreateBrowserContext()); |
| 213 | 209 |
| 214 SetContents(CreateTestWebContents()); | 210 SetContents(CreateTestWebContents()); |
| 215 | 211 |
| 216 if (IsBrowserSideNavigationEnabled()) | 212 if (IsBrowserSideNavigationEnabled()) |
| 217 BrowserSideNavigationSetUp(); | 213 BrowserSideNavigationSetUp(); |
| 218 | |
| 219 #if defined(OS_MACOSX) | |
| 220 ui::WindowResizeHelperMac::Get()->Init( | |
| 221 base::MessageLoop::current()->task_runner()); | |
| 222 #endif // OS_MACOSX | |
| 223 } | 214 } |
| 224 | 215 |
| 225 void RenderViewHostTestHarness::TearDown() { | 216 void RenderViewHostTestHarness::TearDown() { |
| 226 if (IsBrowserSideNavigationEnabled()) | 217 if (IsBrowserSideNavigationEnabled()) |
| 227 BrowserSideNavigationTearDown(); | 218 BrowserSideNavigationTearDown(); |
| 228 | 219 |
| 229 SetContents(NULL); | 220 SetContents(NULL); |
| 230 #if defined(USE_AURA) | 221 #if defined(USE_AURA) |
| 231 aura_test_helper_->TearDown(); | 222 aura_test_helper_->TearDown(); |
| 232 ui::TerminateContextFactoryForTests(); | 223 ui::TerminateContextFactoryForTests(); |
| 233 #endif | 224 #endif |
| 234 // Make sure that we flush any messages related to WebContentsImpl destruction | 225 // Make sure that we flush any messages related to WebContentsImpl destruction |
| 235 // before we destroy the browser context. | 226 // before we destroy the browser context. |
| 236 base::RunLoop().RunUntilIdle(); | 227 base::RunLoop().RunUntilIdle(); |
| 237 | 228 |
| 238 #if defined(OS_MACOSX) | |
| 239 ui::WindowResizeHelperMac::Get()->ShutdownForTests(); | |
| 240 #endif // OS_MACOSX | |
| 241 | |
| 242 #if defined(OS_WIN) | 229 #if defined(OS_WIN) |
| 243 ole_initializer_.reset(); | 230 ole_initializer_.reset(); |
| 244 #endif | 231 #endif |
| 245 | 232 |
| 246 // Delete any RenderProcessHosts before the BrowserContext goes away. | 233 // Delete any RenderProcessHosts before the BrowserContext goes away. |
| 247 if (rvh_test_enabler_.rph_factory_) | 234 if (rvh_test_enabler_.rph_factory_) |
| 248 rvh_test_enabler_.rph_factory_.reset(); | 235 rvh_test_enabler_.rph_factory_.reset(); |
| 249 | 236 |
| 250 // Release the browser context by posting itself on the end of the task | 237 // Release the browser context by posting itself on the end of the task |
| 251 // queue. This is preferable to immediate deletion because it will behave | 238 // queue. This is preferable to immediate deletion because it will behave |
| 252 // properly if the |rph_factory_| reset above enqueued any tasks which | 239 // properly if the |rph_factory_| reset above enqueued any tasks which |
| 253 // depend on |browser_context_|. | 240 // depend on |browser_context_|. |
| 254 BrowserThread::DeleteSoon(content::BrowserThread::UI, | 241 BrowserThread::DeleteSoon(content::BrowserThread::UI, |
| 255 FROM_HERE, | 242 FROM_HERE, |
| 256 browser_context_.release()); | 243 browser_context_.release()); |
| 257 thread_bundle_.reset(); | 244 thread_bundle_.reset(); |
| 258 } | 245 } |
| 259 | 246 |
| 260 BrowserContext* RenderViewHostTestHarness::CreateBrowserContext() { | 247 BrowserContext* RenderViewHostTestHarness::CreateBrowserContext() { |
| 261 return new TestBrowserContext(); | 248 return new TestBrowserContext(); |
| 262 } | 249 } |
| 263 | 250 |
| 264 void RenderViewHostTestHarness::SetRenderProcessHostFactory( | 251 void RenderViewHostTestHarness::SetRenderProcessHostFactory( |
| 265 RenderProcessHostFactory* factory) { | 252 RenderProcessHostFactory* factory) { |
| 266 rvh_test_enabler_.rvh_factory_->set_render_process_host_factory(factory); | 253 rvh_test_enabler_.rvh_factory_->set_render_process_host_factory(factory); |
| 267 } | 254 } |
| 268 | 255 |
| 269 } // namespace content | 256 } // namespace content |
| OLD | NEW |