| 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" | |
| 27 #include "ui/compositor/test/context_factories_for_test.h" | 26 #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(aura_test_helper_ != NULL); | 134 DCHECK(wm_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 aura_test_helper_.reset( | 174 wm_test_helper_.reset(new wm::WMTestHelper); |
| 175 new aura::test::AuraTestHelper(base::MessageLoopForUI::current())); | 175 wm_test_helper_->SetUp(); |
| 176 aura_test_helper_->SetUp(); | |
| 177 #endif | 176 #endif |
| 178 | 177 |
| 179 DCHECK(!browser_context_); | 178 DCHECK(!browser_context_); |
| 180 browser_context_.reset(CreateBrowserContext()); | 179 browser_context_.reset(CreateBrowserContext()); |
| 181 | 180 |
| 182 SetContents(CreateTestWebContents()); | 181 SetContents(CreateTestWebContents()); |
| 183 } | 182 } |
| 184 | 183 |
| 185 void RenderViewHostTestHarness::TearDown() { | 184 void RenderViewHostTestHarness::TearDown() { |
| 186 SetContents(NULL); | 185 SetContents(NULL); |
| 187 #if defined(USE_AURA) | 186 #if defined(USE_AURA) |
| 188 aura_test_helper_->TearDown(); | 187 wm_test_helper_->TearDown(); |
| 189 ui::TerminateContextFactoryForTests(); | 188 ui::TerminateContextFactoryForTests(); |
| 190 #endif | 189 #endif |
| 191 // Make sure that we flush any messages related to WebContentsImpl destruction | 190 // Make sure that we flush any messages related to WebContentsImpl destruction |
| 192 // before we destroy the browser context. | 191 // before we destroy the browser context. |
| 193 base::RunLoop().RunUntilIdle(); | 192 base::RunLoop().RunUntilIdle(); |
| 194 | 193 |
| 195 #if defined(OS_WIN) | 194 #if defined(OS_WIN) |
| 196 ole_initializer_.reset(); | 195 ole_initializer_.reset(); |
| 197 #endif | 196 #endif |
| 198 | 197 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 213 BrowserContext* RenderViewHostTestHarness::CreateBrowserContext() { | 212 BrowserContext* RenderViewHostTestHarness::CreateBrowserContext() { |
| 214 return new TestBrowserContext(); | 213 return new TestBrowserContext(); |
| 215 } | 214 } |
| 216 | 215 |
| 217 void RenderViewHostTestHarness::SetRenderProcessHostFactory( | 216 void RenderViewHostTestHarness::SetRenderProcessHostFactory( |
| 218 RenderProcessHostFactory* factory) { | 217 RenderProcessHostFactory* factory) { |
| 219 rvh_test_enabler_.rvh_factory_->set_render_process_host_factory(factory); | 218 rvh_test_enabler_.rvh_factory_->set_render_process_host_factory(factory); |
| 220 } | 219 } |
| 221 | 220 |
| 222 } // namespace content | 221 } // namespace content |
| OLD | NEW |